RDMA/ucma: Correct option size check using optlen
[pandora-kernel.git] / drivers / hwmon / amc6821.c
index 4033974..b7f3356 100644 (file)
@@ -360,11 +360,13 @@ static ssize_t set_pwm1_enable(
        if (config)
                return config;
 
+       mutex_lock(&data->update_lock);
        config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF1);
        if (config < 0) {
                        dev_err(&client->dev,
                        "Error reading configuration register, aborting.\n");
-                       return -EIO;
+                       count = config;
+                       goto unlock;
        }
 
        switch (val) {
@@ -381,14 +383,15 @@ static ssize_t set_pwm1_enable(
                config |= AMC6821_CONF1_FDRC1;
                break;
        default:
-               return -EINVAL;
+               count = -EINVAL;
+               goto unlock;
        }
-       mutex_lock(&data->update_lock);
        if (i2c_smbus_write_byte_data(client, AMC6821_REG_CONF1, config)) {
                        dev_err(&client->dev,
                        "Configuration register write error, aborting.\n");
                        count = -EIO;
        }
+unlock:
        mutex_unlock(&data->update_lock);
        return count;
 }
@@ -495,8 +498,9 @@ static ssize_t set_temp_auto_point_temp(
                return -EINVAL;
        }
 
-       data->valid = 0;
        mutex_lock(&data->update_lock);
+       data->valid = 0;
+
        switch (ix) {
        case 0:
                ptemp[0] = SENSORS_LIMIT(val / 1000, 0,
@@ -669,13 +673,14 @@ static ssize_t set_fan1_div(
        if (config)
                return config;
 
+       mutex_lock(&data->update_lock);
        config = i2c_smbus_read_byte_data(client, AMC6821_REG_CONF4);
        if (config < 0) {
                dev_err(&client->dev,
                        "Error reading configuration register, aborting.\n");
-               return -EIO;
+               count = config;
+               goto EXIT;
        }
-       mutex_lock(&data->update_lock);
        switch (val) {
        case 2:
                config &= ~AMC6821_CONF4_PSPR;
@@ -715,7 +720,7 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO,
        get_temp_alarm, NULL, IDX_TEMP1_MAX);
 static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO,
        get_temp_alarm, NULL, IDX_TEMP1_CRIT);
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO | S_IWUSR,
+static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO,
        get_temp, NULL, IDX_TEMP2_INPUT);
 static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, get_temp,
        set_temp, IDX_TEMP2_MIN);