]> Pileus Git - ~andy/linux/blobdiff - drivers/hwmon/ds1621.c
hwmon-vid: Don't spam the logs when VRM version is missing
[~andy/linux] / drivers / hwmon / ds1621.c
index 478eb4bb8570958464f57f582c8ee6d52c4edadb..d5ac422d73b2f9d076fa11135715be4ff4b7ae84 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/hwmon.h>
 #include <linux/err.h>
 #include <linux/mutex.h>
+#include <linux/sysfs.h>
 #include "lm75.h"
 
 /* Addresses to scan */
@@ -52,8 +53,8 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
 
 /* The DS1621 registers */
 #define DS1621_REG_TEMP                        0xAA /* word, RO */
-#define DS1621_REG_TEMP_MIN            0xA1 /* word, RW */
-#define DS1621_REG_TEMP_MAX            0xA2 /* word, RW */
+#define DS1621_REG_TEMP_MIN            0xA2 /* word, RW */
+#define DS1621_REG_TEMP_MAX            0xA1 /* word, RW */
 #define DS1621_REG_CONF                        0xAC /* byte, RW */
 #define DS1621_COM_START               0xEE /* no data */
 #define DS1621_COM_STOP                        0x22 /* no data */
@@ -178,6 +179,18 @@ static DEVICE_ATTR(temp1_input, S_IRUGO , show_temp, NULL);
 static DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO , show_temp_min, set_temp_min);
 static DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, set_temp_max);
 
+static struct attribute *ds1621_attributes[] = {
+       &dev_attr_temp1_input.attr,
+       &dev_attr_temp1_min.attr,
+       &dev_attr_temp1_max.attr,
+       &dev_attr_alarms.attr,
+       NULL
+};
+
+static const struct attribute_group ds1621_group = {
+       .attrs = ds1621_attributes,
+};
+
 
 static int ds1621_attach_adapter(struct i2c_adapter *adapter)
 {
@@ -253,21 +266,19 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address,
        ds1621_init_client(new_client);
 
        /* Register sysfs hooks */
+       if ((err = sysfs_create_group(&new_client->dev.kobj, &ds1621_group)))
+               goto exit_detach;
+
        data->class_dev = hwmon_device_register(&new_client->dev);
        if (IS_ERR(data->class_dev)) {
                err = PTR_ERR(data->class_dev);
-               goto exit_detach;
+               goto exit_remove_files;
        }
 
-       device_create_file(&new_client->dev, &dev_attr_alarms);
-       device_create_file(&new_client->dev, &dev_attr_temp1_input);
-       device_create_file(&new_client->dev, &dev_attr_temp1_min);
-       device_create_file(&new_client->dev, &dev_attr_temp1_max);
-       
        return 0;
 
-/* OK, this is not exactly good programming practice, usually. But it is
-   very code-efficient in this case. */
+      exit_remove_files:
+       sysfs_remove_group(&new_client->dev.kobj, &ds1621_group);
       exit_detach:
        i2c_detach_client(new_client);
       exit_free:
@@ -282,6 +293,7 @@ static int ds1621_detach_client(struct i2c_client *client)
        int err;
 
        hwmon_device_unregister(data->class_dev);
+       sysfs_remove_group(&client->dev.kobj, &ds1621_group);
 
        if ((err = i2c_detach_client(client)))
                return err;
@@ -316,9 +328,9 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
 
                /* reset alarms if necessary */
                new_conf = data->conf;
-               if (data->temp < data->temp_min)
+               if (data->temp > data->temp_min)
                        new_conf &= ~DS1621_ALARM_TEMP_LOW;
-               if (data->temp > data->temp_max)
+               if (data->temp < data->temp_max)
                        new_conf &= ~DS1621_ALARM_TEMP_HIGH;
                if (data->conf != new_conf)
                        ds1621_write_value(client, DS1621_REG_CONF,