REG: 1C/bit, two's complement */
static inline s8 TEMP_TO_REG(int val)
{
- return SENSORS_LIMIT(SCALE(val, 1, 1000), -128000, 127000);
+ return SCALE(SENSORS_LIMIT(val, -128000, 127000), 1, 1000);
}
static inline int TEMP_FROM_REG(s8 val)
const char *buf, size_t count)
{
struct smsc47m192_data *data = dev_get_drvdata(dev);
- data->vrm = simple_strtoul(buf, NULL, 10);
+ unsigned long val;
+
+ val = simple_strtoul(buf, NULL, 10);
+ if (val > 255)
+ return -EINVAL;
+
+ data->vrm = val;
return count;
}
static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);