Fix a number of zero-day bugs, mostly found with module test scripts.
Nothing major, but potentially annoying and worthwhile to fix. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJTvCJCAAoJEMsfJm/On5mB1J0QAIWyzyNIpvKpMb3s7lf282vu zsBkIa6/7Bigi9cOdpI9HuMgI6tqtbakYGyja/sZyiVmcS8VMzn8qC2Ae3cqJhr9 bOxY+l8qnQ75nauE99SuLul4tRqMi5WLOUnoCwZgH1uQegR4Ap9ffnVz8l2U9ZoF 8UsigejxIxcSGZ3L1ad9Al6IWzrnWVKGxbbaZB2EjKthwN2ptjhlUxBjNRAvwMtC SC3YrFGpFnJ1FY9kioCY7eKm37FbZ3ZlCGu+EhDNhQbXa7WQYMlEQLvFux7Cf7qG gYMV+IrPks8gkDXHqMcyaDwQVH8+Agd9CpD4HRf5yotT7e6dzOcSjRmJY/Dw50W4 AG3XIy6VQkdGfpiuKoljYnvSxMWzfyy48cE0QbCTDLcB07lENw6VyB0zsDWvmvsp RXAdz7Xg6GsRYUXBcKNNxG4g1MV4eYkoNMyW4eLJ9uqwQ0Kf1JYwg+w4tmtG20s5 zb5FhnHT1Zr/b1Z7EsbX5YXEM9CKchjRPDwzjtLZiu5FQaupMDwUeQggLcCue5Tp RwkMuzO0JpThkgswKHhkmuvlKJPrt8eVr9J4aAaymiZXGa/5P0aDelI4+eWJp4cr yMwzKLxv9e9MELKRCAAfL16IJDTO570gENMyuRU17TSYCVnIklNfdZ9XAhxFOtbJ 8SUxBvC3l3bdjuXXhKaD =otbz -----END PGP SIGNATURE----- Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon fixes from Guenter Roeck: "Fix a number of zero-day bugs, mostly found with module test scripts. Nothing major, but potentially annoying and worthwhile to fix" * tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (adc128d818) Drop write support on inX_input attributes hwmon: (emc2103) Clamp limits instead of bailing out hwmon: (adm1031) Fix writes to limit registers hwmon: (adm1021) Fix cache problem when writing temperature limits hwmon: (adm1029) Ensure the fan_div cache is updated in set_fan_div hwmon: (amc6821) Fix permissions for temp2_input hwmon: (ntc_thermistor) Correct information printed during probe
This commit is contained in:
commit
163e40743f
|
@ -239,50 +239,50 @@ static ssize_t adc128_show_alarm(struct device *dev,
|
|||
return sprintf(buf, "%u\n", !!(alarms & mask));
|
||||
}
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in0_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 0, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 0, 2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in1_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 1, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 1, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 1, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 1, 2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in2_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 2, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 2, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 2, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 2, 2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in3_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 3, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 3, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 3, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 3, 2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in4_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 4, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 4, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 4, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 4, 2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in5_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 5, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 5, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 5, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 5, 2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR_2(in6_input, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 6, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in6_input, S_IRUGO,
|
||||
adc128_show_in, NULL, 6, 0);
|
||||
static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO,
|
||||
adc128_show_in, adc128_set_in, 6, 1);
|
||||
static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO,
|
||||
|
|
|
@ -185,7 +185,7 @@ static ssize_t set_temp_max(struct device *dev,
|
|||
struct adm1021_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->client;
|
||||
long temp;
|
||||
int err;
|
||||
int reg_val, err;
|
||||
|
||||
err = kstrtol(buf, 10, &temp);
|
||||
if (err)
|
||||
|
@ -193,10 +193,11 @@ static ssize_t set_temp_max(struct device *dev,
|
|||
temp /= 1000;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_max[index] = clamp_val(temp, -128, 127);
|
||||
reg_val = clamp_val(temp, -128, 127);
|
||||
data->temp_max[index] = reg_val * 1000;
|
||||
if (!read_only)
|
||||
i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index),
|
||||
data->temp_max[index]);
|
||||
reg_val);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
|
@ -210,7 +211,7 @@ static ssize_t set_temp_min(struct device *dev,
|
|||
struct adm1021_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->client;
|
||||
long temp;
|
||||
int err;
|
||||
int reg_val, err;
|
||||
|
||||
err = kstrtol(buf, 10, &temp);
|
||||
if (err)
|
||||
|
@ -218,10 +219,11 @@ static ssize_t set_temp_min(struct device *dev,
|
|||
temp /= 1000;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_min[index] = clamp_val(temp, -128, 127);
|
||||
reg_val = clamp_val(temp, -128, 127);
|
||||
data->temp_min[index] = reg_val * 1000;
|
||||
if (!read_only)
|
||||
i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index),
|
||||
data->temp_min[index]);
|
||||
reg_val);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
|
|
|
@ -232,6 +232,9 @@ static ssize_t set_fan_div(struct device *dev,
|
|||
/* Update the value */
|
||||
reg = (reg & 0x3F) | (val << 6);
|
||||
|
||||
/* Update the cache */
|
||||
data->fan_div[attr->index] = reg;
|
||||
|
||||
/* Write value */
|
||||
i2c_smbus_write_byte_data(client,
|
||||
ADM1029_REG_FAN_DIV[attr->index], reg);
|
||||
|
|
|
@ -365,6 +365,7 @@ set_auto_temp_min(struct device *dev, struct device_attribute *attr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
val = clamp_val(val, 0, 127000);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
|
||||
adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
|
||||
|
@ -394,6 +395,7 @@ set_auto_temp_max(struct device *dev, struct device_attribute *attr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
val = clamp_val(val, 0, 127000);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr],
|
||||
data->pwm[nr]);
|
||||
|
@ -696,7 +698,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875);
|
||||
val = clamp_val(val, -55000, 127000);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_min[nr] = TEMP_TO_REG(val);
|
||||
adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr),
|
||||
|
@ -717,7 +719,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875);
|
||||
val = clamp_val(val, -55000, 127000);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_max[nr] = TEMP_TO_REG(val);
|
||||
adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr),
|
||||
|
@ -738,7 +740,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875);
|
||||
val = clamp_val(val, -55000, 127000);
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_crit[nr] = TEMP_TO_REG(val);
|
||||
adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr),
|
||||
|
|
|
@ -704,7 +704,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);
|
||||
|
|
|
@ -250,9 +250,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *da,
|
|||
if (result < 0)
|
||||
return result;
|
||||
|
||||
val = DIV_ROUND_CLOSEST(val, 1000);
|
||||
if ((val < -63) || (val > 127))
|
||||
return -EINVAL;
|
||||
val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_min[nr] = val;
|
||||
|
@ -274,9 +272,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *da,
|
|||
if (result < 0)
|
||||
return result;
|
||||
|
||||
val = DIV_ROUND_CLOSEST(val, 1000);
|
||||
if ((val < -63) || (val > 127))
|
||||
return -EINVAL;
|
||||
val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->temp_max[nr] = val;
|
||||
|
@ -390,15 +386,14 @@ static ssize_t set_fan_target(struct device *dev, struct device_attribute *da,
|
|||
{
|
||||
struct emc2103_data *data = emc2103_update_device(dev);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
long rpm_target;
|
||||
unsigned long rpm_target;
|
||||
|
||||
int result = kstrtol(buf, 10, &rpm_target);
|
||||
int result = kstrtoul(buf, 10, &rpm_target);
|
||||
if (result < 0)
|
||||
return result;
|
||||
|
||||
/* Datasheet states 16384 as maximum RPM target (table 3.2) */
|
||||
if ((rpm_target < 0) || (rpm_target > 16384))
|
||||
return -EINVAL;
|
||||
rpm_target = clamp_val(rpm_target, 0, 16384);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
|
|
|
@ -512,7 +512,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n",
|
||||
pdev->name);
|
||||
pdev_id->name);
|
||||
|
||||
return 0;
|
||||
err_after_sysfs:
|
||||
|
|
Loading…
Reference in New Issue