aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/adm1021.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r--drivers/hwmon/adm1021.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index f920619cd6da..29dd9f746dfa 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -284,15 +284,11 @@ static DEVICE_ATTR(low_power, S_IWUSR | S_IRUGO, show_low_power, set_low_power);
284 284
285static struct attribute *adm1021_attributes[] = { 285static struct attribute *adm1021_attributes[] = {
286 &sensor_dev_attr_temp1_max.dev_attr.attr, 286 &sensor_dev_attr_temp1_max.dev_attr.attr,
287 &sensor_dev_attr_temp1_min.dev_attr.attr,
288 &sensor_dev_attr_temp1_input.dev_attr.attr, 287 &sensor_dev_attr_temp1_input.dev_attr.attr,
289 &sensor_dev_attr_temp2_max.dev_attr.attr, 288 &sensor_dev_attr_temp2_max.dev_attr.attr,
290 &sensor_dev_attr_temp2_min.dev_attr.attr,
291 &sensor_dev_attr_temp2_input.dev_attr.attr, 289 &sensor_dev_attr_temp2_input.dev_attr.attr,
292 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, 290 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
293 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
294 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, 291 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
295 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
296 &sensor_dev_attr_temp2_fault.dev_attr.attr, 292 &sensor_dev_attr_temp2_fault.dev_attr.attr,
297 &dev_attr_alarms.attr, 293 &dev_attr_alarms.attr,
298 &dev_attr_low_power.attr, 294 &dev_attr_low_power.attr,
@@ -303,6 +299,18 @@ static const struct attribute_group adm1021_group = {
303 .attrs = adm1021_attributes, 299 .attrs = adm1021_attributes,
304}; 300};
305 301
302static struct attribute *adm1021_min_attributes[] = {
303 &sensor_dev_attr_temp1_min.dev_attr.attr,
304 &sensor_dev_attr_temp2_min.dev_attr.attr,
305 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
306 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
307 NULL
308};
309
310static const struct attribute_group adm1021_min_group = {
311 .attrs = adm1021_min_attributes,
312};
313
306/* Return 0 if detection is successful, -ENODEV otherwise */ 314/* Return 0 if detection is successful, -ENODEV otherwise */
307static int adm1021_detect(struct i2c_client *client, 315static int adm1021_detect(struct i2c_client *client,
308 struct i2c_board_info *info) 316 struct i2c_board_info *info)
@@ -425,6 +433,12 @@ static int adm1021_probe(struct i2c_client *client,
425 if (err) 433 if (err)
426 return err; 434 return err;
427 435
436 if (data->type != lm84) {
437 err = sysfs_create_group(&client->dev.kobj, &adm1021_min_group);
438 if (err)
439 goto error;
440 }
441
428 data->hwmon_dev = hwmon_device_register(&client->dev); 442 data->hwmon_dev = hwmon_device_register(&client->dev);
429 if (IS_ERR(data->hwmon_dev)) { 443 if (IS_ERR(data->hwmon_dev)) {
430 err = PTR_ERR(data->hwmon_dev); 444 err = PTR_ERR(data->hwmon_dev);
@@ -434,6 +448,7 @@ static int adm1021_probe(struct i2c_client *client,
434 return 0; 448 return 0;
435 449
436error: 450error:
451 sysfs_remove_group(&client->dev.kobj, &adm1021_min_group);
437 sysfs_remove_group(&client->dev.kobj, &adm1021_group); 452 sysfs_remove_group(&client->dev.kobj, &adm1021_group);
438 return err; 453 return err;
439} 454}
@@ -452,6 +467,7 @@ static int adm1021_remove(struct i2c_client *client)
452 struct adm1021_data *data = i2c_get_clientdata(client); 467 struct adm1021_data *data = i2c_get_clientdata(client);
453 468
454 hwmon_device_unregister(data->hwmon_dev); 469 hwmon_device_unregister(data->hwmon_dev);
470 sysfs_remove_group(&client->dev.kobj, &adm1021_min_group);
455 sysfs_remove_group(&client->dev.kobj, &adm1021_group); 471 sysfs_remove_group(&client->dev.kobj, &adm1021_group);
456 472
457 return 0; 473 return 0;
@@ -477,9 +493,11 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
477 data->temp_max[i] = 1000 * 493 data->temp_max[i] = 1000 *
478 (s8) i2c_smbus_read_byte_data( 494 (s8) i2c_smbus_read_byte_data(
479 client, ADM1021_REG_TOS_R(i)); 495 client, ADM1021_REG_TOS_R(i));
480 data->temp_min[i] = 1000 * 496 if (data->type != lm84) {
481 (s8) i2c_smbus_read_byte_data( 497 data->temp_min[i] = 1000 *
482 client, ADM1021_REG_THYST_R(i)); 498 (s8) i2c_smbus_read_byte_data(client,
499 ADM1021_REG_THYST_R(i));
500 }
483 } 501 }
484 data->alarms = i2c_smbus_read_byte_data(client, 502 data->alarms = i2c_smbus_read_byte_data(client,
485 ADM1021_REG_STATUS) & 0x7c; 503 ADM1021_REG_STATUS) & 0x7c;