aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47b397.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/smsc47b397.c')
-rw-r--r--drivers/hwmon/smsc47b397.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index a85869393bab..72b0e2d8650c 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -176,9 +176,6 @@ sysfs_temp(2);
176sysfs_temp(3); 176sysfs_temp(3);
177sysfs_temp(4); 177sysfs_temp(4);
178 178
179#define device_create_file_temp(client, num) \
180 device_create_file(&client->dev, &dev_attr_temp##num##_input)
181
182/* FAN: 1 RPM/bit 179/* FAN: 1 RPM/bit
183 REG: count of 90kHz pulses / revolution */ 180 REG: count of 90kHz pulses / revolution */
184static int fan_from_reg(u16 reg) 181static int fan_from_reg(u16 reg)
@@ -205,8 +202,22 @@ sysfs_fan(2);
205sysfs_fan(3); 202sysfs_fan(3);
206sysfs_fan(4); 203sysfs_fan(4);
207 204
208#define device_create_file_fan(client, num) \ 205static struct attribute *smsc47b397_attributes[] = {
209 device_create_file(&client->dev, &dev_attr_fan##num##_input) 206 &dev_attr_temp1_input.attr,
207 &dev_attr_temp2_input.attr,
208 &dev_attr_temp3_input.attr,
209 &dev_attr_temp4_input.attr,
210 &dev_attr_fan1_input.attr,
211 &dev_attr_fan2_input.attr,
212 &dev_attr_fan3_input.attr,
213 &dev_attr_fan4_input.attr,
214
215 NULL
216};
217
218static const struct attribute_group smsc47b397_group = {
219 .attrs = smsc47b397_attributes,
220};
210 221
211static int smsc47b397_detach_client(struct i2c_client *client) 222static int smsc47b397_detach_client(struct i2c_client *client)
212{ 223{
@@ -214,6 +225,7 @@ static int smsc47b397_detach_client(struct i2c_client *client)
214 int err; 225 int err;
215 226
216 hwmon_device_unregister(data->class_dev); 227 hwmon_device_unregister(data->class_dev);
228 sysfs_remove_group(&client->dev.kobj, &smsc47b397_group);
217 229
218 if ((err = i2c_detach_client(client))) 230 if ((err = i2c_detach_client(client)))
219 return err; 231 return err;
@@ -268,24 +280,19 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
268 if ((err = i2c_attach_client(new_client))) 280 if ((err = i2c_attach_client(new_client)))
269 goto error_free; 281 goto error_free;
270 282
283 if ((err = sysfs_create_group(&new_client->dev.kobj, &smsc47b397_group)))
284 goto error_detach;
285
271 data->class_dev = hwmon_device_register(&new_client->dev); 286 data->class_dev = hwmon_device_register(&new_client->dev);
272 if (IS_ERR(data->class_dev)) { 287 if (IS_ERR(data->class_dev)) {
273 err = PTR_ERR(data->class_dev); 288 err = PTR_ERR(data->class_dev);
274 goto error_detach; 289 goto error_remove;
275 } 290 }
276 291
277 device_create_file_temp(new_client, 1);
278 device_create_file_temp(new_client, 2);
279 device_create_file_temp(new_client, 3);
280 device_create_file_temp(new_client, 4);
281
282 device_create_file_fan(new_client, 1);
283 device_create_file_fan(new_client, 2);
284 device_create_file_fan(new_client, 3);
285 device_create_file_fan(new_client, 4);
286
287 return 0; 292 return 0;
288 293
294error_remove:
295 sysfs_remove_group(&new_client->dev.kobj, &smsc47b397_group);
289error_detach: 296error_detach:
290 i2c_detach_client(new_client); 297 i2c_detach_client(new_client);
291error_free: 298error_free: