Skip to contentSkip to conversation

hwmon: (f75375s) Fix writes to the pwm* attribute for the F75387

PATCH Applied Nikolaus Schulz 2 participants 3 messages Feb 28, 2012 – Mar 2, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 hwmon: (f75375s) Fix writes to the pwm* attribute for the F75387

For the F75387, the register holding the current PWM duty cycle value is r/o; changing it requires writing to the fan expect register instead.

---
 drivers/hwmon/f75375s.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
drivers/hwmon/f75375s.c +12 -5
index 5dae122..1c26652 100644
@@ -178,6 +178,15 @@ static inline void f75375_write16(struct i2c_client *client, u8 reg,
 	i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF));
 }
 
+static void f75375_write_pwm(struct i2c_client *client, int nr, u8 pwm)
+{
+	struct f75375_data *data = i2c_get_clientdata(client);
+	if (data->kind = f75387)
+		f75375_write16(client, F75375_REG_FAN_EXP(nr), pwm);
+	else
+		f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), pwm);
+}
+
 static struct f75375_data *f75375_update_device(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -309,7 +318,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 	mutex_lock(&data->update_lock);
 	data->pwm[nr] = SENSORS_LIMIT(val, 0, 255);
-	f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr), data->pwm[nr]);
+	f75375_write_pwm(client, nr, data->pwm[nr]);
 	mutex_unlock(&data->update_lock);
 	return count;
 }
@@ -374,8 +383,7 @@ static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
 	f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
 	data->pwm_enable[nr] = val;
 	if (val = 0)
-		f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
-				data->pwm[nr]);
+		f75375_write_pwm(client, nr, data->pwm[nr]);
 	return 0;
 }
 
@@ -759,8 +767,7 @@ static void f75375_init(struct i2c_client *client, struct f75375_data *data,
 	set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]);
 	for (nr = 0; nr < 2; nr++) {
 		data->pwm[nr] = SENSORS_LIMIT(f75375s_pdata->pwm[nr], 0, 255);
-		f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
-			data->pwm[nr]);
+		f75375_write_pwm(client, nr, data->pwm[nr]);
 	}
 
 }
Signature · 7 lines
1.7.9.1


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 13 lines · Nikolaus Schulz

For the F75387, the register holding the current PWM duty cycle value is r/o; changing it requires writing to the fan expect register instead.

---
 drivers/hwmon/f75375s.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
drivers/hwmon/f75375s.c +0 -0
index 5dae122..1c26652 100644

drivers/hwmon/f75375s.c static inline void f75375_write16(struct i2c_client *client, u8 reg, · line 183

Quoted 6 lines
drivers/hwmon/f75375s.c +3 -0
@@ -178,6 +178,15 @@ static inline void f75375_write16(struct i2c_client *client, u8 reg,
 	i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF));
 }
 
+static void f75375_write_pwm(struct i2c_client *client, int nr, u8 pwm)
+{
+	struct f75375_data *data = i2c_get_clientdata(client);

Since you extract data anyway, you don't need to pass pwm but can instead take if from data->pwm[nr].

Other than that, looks good.

No need to resubmit; I can make that change myself if you agree.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#2 lore raw
In reply to Nikolaus Schulz
Quoted 24 lines · Guenter Roeck
Quoted 13 lines · Nikolaus Schulz

For the F75387, the register holding the current PWM duty cycle value is r/o; changing it requires writing to the fan expect register instead.

---
 drivers/hwmon/f75375s.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
drivers/hwmon/f75375s.c +0 -0
index 5dae122..1c26652 100644

drivers/hwmon/f75375s.c static inline void f75375_write16(struct i2c_client *client, u8 reg, · line 183

Quoted 6 lines
drivers/hwmon/f75375s.c +3 -0
@@ -178,6 +178,15 @@ static inline void f75375_write16(struct i2c_client *client, u8 reg,
 	i2c_smbus_write_byte_data(client, reg + 1, (value & 0xFF));
 }
 
+static void f75375_write_pwm(struct i2c_client *client, int nr, u8 pwm)
+{
+	struct f75375_data *data = i2c_get_clientdata(client);

Since you extract data anyway, you don't need to pass pwm but can instead take if from data->pwm[nr].

Quoted 3 lines

Other than that, looks good.

No need to resubmit; I can make that change myself if you agree.

That's ok, please proceed.

Thanks,
Nikolaus

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors