Updated from Linux LTS 3.10.24 to 3.10.25
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
* @last_update: time of last update (jiffies)
|
||||
* @temperature: cached temperature measurement value
|
||||
* @humidity: cached humidity measurement value
|
||||
* @write_length: length for I2C measurement request
|
||||
*/
|
||||
struct hih6130 {
|
||||
struct device *hwmon_dev;
|
||||
@@ -51,6 +52,7 @@ struct hih6130 {
|
||||
unsigned long last_update;
|
||||
int temperature;
|
||||
int humidity;
|
||||
size_t write_length;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -121,8 +123,15 @@ static int hih6130_update_measurements(struct i2c_client *client)
|
||||
*/
|
||||
if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) {
|
||||
|
||||
/* write to slave address, no data, to request a measurement */
|
||||
ret = i2c_master_send(client, tmp, 0);
|
||||
/*
|
||||
* Write to slave address to request a measurement.
|
||||
* According with the datasheet it should be with no data, but
|
||||
* for systems with I2C bus drivers that do not allow zero
|
||||
* length packets we write one dummy byte to allow sensor
|
||||
* measurements on them.
|
||||
*/
|
||||
tmp[0] = 0;
|
||||
ret = i2c_master_send(client, tmp, hih6130->write_length);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
@@ -252,6 +261,9 @@ static int hih6130_probe(struct i2c_client *client,
|
||||
goto fail_remove_sysfs;
|
||||
}
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK))
|
||||
hih6130->write_length = 1;
|
||||
|
||||
return 0;
|
||||
|
||||
fail_remove_sysfs:
|
||||
|
||||
@@ -94,6 +94,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
|
||||
{
|
||||
if (rpm <= 0)
|
||||
return 255;
|
||||
if (rpm > 1350000)
|
||||
return 1;
|
||||
return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
|
||||
{
|
||||
if (rpm <= 0)
|
||||
return 255;
|
||||
if (rpm > 1350000)
|
||||
return 1;
|
||||
return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 };
|
||||
*/
|
||||
static inline u8 FAN_TO_REG(long rpm, int div)
|
||||
{
|
||||
if (rpm == 0)
|
||||
if (rpm <= 0 || rpm > 1310720)
|
||||
return 0;
|
||||
return clamp_val(1310720 / (rpm * div), 1, 255);
|
||||
}
|
||||
|
||||
@@ -481,9 +481,11 @@ store_pwm(struct device *dev, struct device_attribute *attr,
|
||||
if (err)
|
||||
return err;
|
||||
val = clamp_val(val, 0, 255);
|
||||
val = DIV_ROUND_CLOSEST(val, 0x11);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
data->pwm[nr] = val;
|
||||
data->pwm[nr] = val * 0x11;
|
||||
val |= w83l786ng_read_value(client, W83L786NG_REG_PWM[nr]) & 0xf0;
|
||||
w83l786ng_write_value(client, W83L786NG_REG_PWM[nr], val);
|
||||
mutex_unlock(&data->update_lock);
|
||||
return count;
|
||||
@@ -510,7 +512,7 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
|
||||
mutex_lock(&data->update_lock);
|
||||
reg = w83l786ng_read_value(client, W83L786NG_REG_FAN_CFG);
|
||||
data->pwm_enable[nr] = val;
|
||||
reg &= ~(0x02 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
|
||||
reg &= ~(0x03 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
|
||||
reg |= (val - 1) << W83L786NG_PWM_ENABLE_SHIFT[nr];
|
||||
w83l786ng_write_value(client, W83L786NG_REG_FAN_CFG, reg);
|
||||
mutex_unlock(&data->update_lock);
|
||||
@@ -776,9 +778,10 @@ static struct w83l786ng_data *w83l786ng_update_device(struct device *dev)
|
||||
((pwmcfg >> W83L786NG_PWM_MODE_SHIFT[i]) & 1)
|
||||
? 0 : 1;
|
||||
data->pwm_enable[i] =
|
||||
((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 2) + 1;
|
||||
data->pwm[i] = w83l786ng_read_value(client,
|
||||
W83L786NG_REG_PWM[i]);
|
||||
((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 3) + 1;
|
||||
data->pwm[i] =
|
||||
(w83l786ng_read_value(client, W83L786NG_REG_PWM[i])
|
||||
& 0x0f) * 0x11;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user