V4L/DVB (4363): V4L2 conversion: radio-trust
[safe/jmp/linux-2.6] / drivers / hwmon / vt8231.c
index c2eb54b..686f3de 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/hwmon-vid.h>
 #include <linux/err.h>
+#include <linux/mutex.h>
 #include <asm/io.h>
 
 static int force_addr;
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
 
 struct vt8231_data {
        struct i2c_client client;
-       struct semaphore update_lock;
+       struct mutex update_lock;
        struct class_device *class_dev;
        char valid;             /* !=0 if following fields are valid */
        unsigned long last_updated;     /* In jiffies */
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
        vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
        vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
                                        0, 255);
        vt8231_write_value(client, regvoltmin[5], data->in_min[5]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        unsigned long val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
                                        0, 255);
        vt8231_write_value(client, regvoltmax[5], data->in_max[5]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
        vt8231_write_value(client, regtempmax[0], data->temp_max[0]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
        vt8231_write_value(client, regtempmin[0], data->temp_min[0]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
        vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        int val = simple_strtol(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
        vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -437,12 +438,12 @@ static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO,          \
                show_temp, NULL, offset - 1);                           \
 static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR,       \
                show_temp_max, set_temp_max, offset - 1);               \
-static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR,       \
+static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR,  \
                show_temp_min, set_temp_min, offset - 1)
 
 static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp0, NULL);
 static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp0_max, set_temp0_max);
-static DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp0_min, set_temp0_min);
+static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp0_min, set_temp0_min);
 
 define_temperature_sysfs(2);
 define_temperature_sysfs(3);
@@ -451,7 +452,7 @@ define_temperature_sysfs(5);
 define_temperature_sysfs(6);
 
 #define CFG_INFO_TEMP(id)      { &sensor_dev_attr_temp##id##_input.dev_attr, \
-                               &sensor_dev_attr_temp##id##_min.dev_attr, \
+                               &sensor_dev_attr_temp##id##_max_hyst.dev_attr, \
                                &sensor_dev_attr_temp##id##_max.dev_attr }
 #define CFG_INFO_VOLT(id)      { &sensor_dev_attr_in##id##_input.dev_attr, \
                                &sensor_dev_attr_in##id##_min.dev_attr, \
@@ -464,7 +465,7 @@ struct str_device_attr_table {
 };
 
 static struct str_device_attr_table cfg_info_temp[] = {
-       { &dev_attr_temp1_input, &dev_attr_temp1_min, &dev_attr_temp1_max },
+       { &dev_attr_temp1_input, &dev_attr_temp1_max_hyst, &dev_attr_temp1_max },
        CFG_INFO_TEMP(2),
        CFG_INFO_TEMP(3),
        CFG_INFO_TEMP(4),
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
        struct vt8231_data *data = i2c_get_clientdata(client);
        int val = simple_strtoul(buf, NULL, 10);
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
        vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
        long min = FAN_FROM_REG(data->fan_min[nr],
                                 DIV_FROM_REG(data->fan_div[nr]));
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
        switch (val) {
        case 1: data->fan_div[nr] = 0; break;
        case 2: data->fan_div[nr] = 1; break;
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
        default:
                dev_err(&client->dev, "fan_div value %ld not supported."
                        "Choose one of 1, 2, 4 or 8!\n", val);
-               up(&data->update_lock);
+               mutex_unlock(&data->update_lock);
                return -EINVAL;
        }
 
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
 
        old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
        vt8231_write_value(client, VT8231_REG_FANDIV, old);
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
        return count;
 }
 
@@ -586,7 +587,6 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
 
 static struct i2c_driver vt8231_driver = {
        .driver = {
-               .owner  = THIS_MODULE,
                .name   = "vt8231",
        },
        .attach_adapter = vt8231_detect,
@@ -661,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter)
        /* Fill in the remaining client fields and put into the global list */
        strlcpy(client->name, "vt8231", I2C_NAME_SIZE);
 
-       init_MUTEX(&data->update_lock);
+       mutex_init(&data->update_lock);
 
        /* Tell the I2C layer a new client has arrived */
        if ((err = i2c_attach_client(client)))
@@ -746,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev)
        int i;
        u16 low;
 
-       down(&data->update_lock);
+       mutex_lock(&data->update_lock);
 
        if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
            || !data->valid) {
@@ -805,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev)
                data->valid = 1;
        }
 
-       up(&data->update_lock);
+       mutex_unlock(&data->update_lock);
 
        return data;
 }
@@ -842,7 +842,7 @@ static int __devinit vt8231_pci_probe(struct pci_dev *dev,
 
 static int __init sm_vt8231_init(void)
 {
-       return pci_module_init(&vt8231_pci_driver);
+       return pci_register_driver(&vt8231_pci_driver);
 }
 
 static void __exit sm_vt8231_exit(void)