Skip to contentSkip to conversation

PATCH [4/4]: hwmon: f71882fg add support for the

lm-sensors Hans de Goede 2 participants 4 messages May 29, 2009 – May 31, 2009

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

Add support for the hwmon part of the Fintek f71858fg superio IC to the f71882fg driver. Many thanks to Jelle de Jong for lending me a motherboard with this superio on it.

hwmon: f71882fg add support for the f71858fg

Add support for the hwmon part of the Fintek f71858fg superio IC to the f71882fg driver. Many thanks to Jelle de Jong for lending me a motherboard with this superio on it.

Documentation/hwmon/f71882fg renamed from Documentation/hwmon/f71882fg.f71858fg +8 -4
diff -up vanilla-2.6.30-rc6-git2/Documentation/hwmon/f71882fg.f71858fg vanilla-2.6.30-rc6-git2/Documentation/hwmon/f71882fg
@@ -2,14 +2,18 @@ Kernel driver f71882fg
 ======================
 
 Supported chips:
-  * Fintek F71882FG and F71883FG
-    Prefix: 'f71882fg'
+  * Fintek F71858FG
+    Prefix: 'f71858fg'
     Addresses scanned: none, address read from Super I/O config space
     Datasheet: Available from the Fintek website
   * Fintek F71862FG and F71863FG
     Prefix: 'f71862fg'
     Addresses scanned: none, address read from Super I/O config space
     Datasheet: Available from the Fintek website
+  * Fintek F71882FG and F71883FG
+    Prefix: 'f71882fg'
+    Addresses scanned: none, address read from Super I/O config space
+    Datasheet: Available from the Fintek website
   * Fintek F8000
     Prefix: 'f8000'
     Addresses scanned: none, address read from Super I/O config space
@@ -66,13 +70,13 @@ printed when loading the driver.
 
 Three different fan control modes are supported; the mode number is written
 to the pwm#_enable file. Note that not all modes are supported on all
-chips, and some modes may only be available in RPM / PWM mode on the F8000.
+chips, and some modes may only be available in RPM / PWM mode.
 Writing an unsupported mode will result in an invalid parameter error.
 
 * 1: Manual mode
   You ask for a specific PWM duty cycle / DC voltage or a specific % of
   fan#_full_speed by writing to the pwm# file. This mode is only
-  available on the F8000 if the fan channel is in RPM mode.
+  available on the F71858FG / F8000 if the fan channel is in RPM mode.
 
 * 2: Normal auto mode
   You can define a number of temperature/fan speed trip points, which % the
drivers/hwmon/Kconfig renamed from drivers/hwmon/Kconfig.f71858fg +2 -2
diff -up vanilla-2.6.30-rc6-git2/drivers/hwmon/Kconfig.f71858fg vanilla-2.6.30-rc6-git2/drivers/hwmon/Kconfig
@@ -306,11 +306,11 @@ config SENSORS_F71805F
 	  will be called f71805f.
 
 config SENSORS_F71882FG
-	tristate "Fintek F71862FG, F71882FG and F8000"
+	tristate "Fintek F71858FG, F71862FG, F71882FG and F8000"
 	depends on EXPERIMENTAL
 	help
 	  If you say yes here you get support for hardware monitoring
-	  features of the Fintek F71882FG/F71883FG, F71862FG/71863FG
+	  features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG
 	  and F8000 Super-I/O chips.
 
 	  This driver can also be built as a module.  If so, the module
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +152 -32

330 lines not on this page · raw message

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

#1 lore raw

Hi Hans,

Quoted 5 lines · Hans de Goede

Add support for the hwmon part of the Fintek f71858fg superio IC to the f71882fg driver. Many thanks to Jelle de Jong for lending me a motherboard with this superio on it.

Review:

Review

Quoted 10 lines

(...)
static struct f71882fg_data *f71882fg_update_device(struct device *dev) {

(quoted diff) +2 -2
 	struct f71882fg_data *data = dev_get_drvdata(dev);
 	int nr, reg = 0, reg2;
 	int nr_fans = (data->type = f71882fg) ? 4 : 3;
-	int nr_ins = (data->type = f8000) ? 3 : 9;
-	int temp_start = (data->type = f8000) ? 0 : 1;
+	int nr_ins = (data->type = f71858fg || data->type = f8000) ? 3 : 9;
+	int temp_start > +	    (data->type = f71858fg || data->type = f8000) ? 0 : 1;

It might be a good idea to add these values to struct f71882fg_data (maybe in a separate patch) so that you don't have to compute them every time. Especially temp_start is used in several functions.

drivers/hwmon/f71882fg.c static ssize_t show_temp(struct device * · line 1236

Quoted 13 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +4 -0
 	mutex_lock(&data->update_lock);
 
 
(...)
@@ -1166,8 +1230,22 @@ static ssize_t show_temp(struct device *
 {
 	struct f71882fg_data *data = f71882fg_update_device(dev);
 	int nr = to_sensor_dev_attr_2(devattr)->index;
+	int sign, temp;
+
+	if (data->type = f71858fg) {
+		if ((data->temp_config & 3) = 3)

If I read the datasheet correctly, this should be:

		if ((data->temp_config & 1) = 1)

Both modes 1 and 3 have the sign in the LSb while modes 0 and 2 have the sign in the MSb.

drivers/hwmon/f71882fg.c static ssize_t show_temp(struct device * · line 1241

Quoted 5 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +5 -0
+			sign = data->temp[nr] & 0x0001;
+		else
+			sign = data->temp[nr] & 0x8000;
+
+		temp = (data->temp[nr] >> 5) & 0x3ff;

This is only correct for modes 0 and 2. For modes 1 and 3, there are 11 bits of data, not 10, so the mask should be 0x7ff.

Quoted 12 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +6 -1
+		temp *= 125;
+		if (sign)
+			temp -= 128000;
+	} else
+		temp = data->temp[nr] * 1000;
 
-	return sprintf(buf, "%d\n", data->temp[nr] * 1000);
+	return sprintf(buf, "%d\n", temp);
 }
 
 static ssize_t show_temp_max(struct device *dev, struct device_attribute

drivers/hwmon/f71882fg.c static ssize_t store_pwm_enable(struct d · line 1543

Quoted 6 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +3 -0
@@ -1460,6 +1538,12 @@ static ssize_t store_pwm_enable(struct d
 	} else {
 		switch (val) {
 		case 1:
+			/* The f71858fg does not support manual RPM mode */
+			if (data->type = f71858fg &&
+			    ((data->pwm_enable >> 2 * nr) & 1)) {

I strongly suggest adding parentheses. The precendence of >> vs. * is always confusing, better make it obvious with parentheses.

Quoted 9 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +3 -0
+				count = -EINVAL;
+				goto leave;
+			}
 			data->pwm_enable |= 2 << (2 * nr);
 			break;		/* Manual */
 		case 2:
 
(...)

drivers/hwmon/f71882fg.c static int __devinit f71882fg_probe(stru · line 1879

Quoted 7 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +4 -0
@@ -1773,6 +1873,12 @@ static int __devinit f71882fg_probe(stru
 
 		/* Sanity check the pwm settings */
 		switch (data->type) {
+		case f71858fg:
+			err = 0;
+			for (i = 0; i < nr_fans; i++)
+				if (((data->pwm_enable >> i * 2) & 3) = 3)

Ditto for parentheses.

drivers/hwmon/f71882fg.c static int __devinit f71882fg_probe(stru · line 1884

Quoted 5 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +2 -0
+					err = 1;
+			break;
 		case f71862fg:
 			err = (data->pwm_enable & 0x15) != 0x15;
 			break;

All the rest looks good to me.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Hans de Goede
Quoted 11 lines · Jean Delvare

Hi Hans,

Quoted 5 lines · Hans de Goede

Add support for the hwmon part of the Fintek f71858fg superio IC to the f71882fg driver. Many thanks to Jelle de Jong for lending me a motherboard with this superio on it.

Review:

Many thanks for the quick review !

Quoted 7 lines
Quoted 7 lines

(...)
static struct f71882fg_data *f71882fg_update_device(struct device *dev) {
struct f71882fg_data *data = dev_get_drvdata(dev); int nr, reg = 0, reg2;
int nr_fans = (data->type == f71882fg) ? 4 : 3;

(quoted diff) +0 -1
-	int nr_ins = (data->type == f8000) ? 3 : 9;
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +3 -1
-	int temp_start = (data->type == f8000) ? 0 : 1;
+	int nr_ins = (data->type == f71858fg || data->type == f8000) ? 3 : 9;
+	int temp_start =
+	    (data->type == f71858fg || data->type == f8000) ? 0 : 1;

It might be a good idea to add these values to struct f71882fg_data (maybe in a separate patch) so that you don't have to compute them every time. Especially temp_start is used in several functions.

I've done this for temp_start.

Quoted 17 lines

Review static ssize_t show_temp(struct device * · line 1236

Quoted 9 lines

(...)

(quoted diff) +4 -0
@@ -1166,8 +1230,22 @@ static ssize_t show_temp(struct device *
  {
  	struct f71882fg_data *data = f71882fg_update_device(dev);
  	int nr = to_sensor_dev_attr_2(devattr)->index;
+	int sign, temp;
+
+	if (data->type == f71858fg) {
+		if ((data->temp_config&  3) == 3)

If I read the datasheet correctly, this should be:

		if ((data->temp_config&  1) == 1)

Both modes 1 and 3 have the sign in the LSb while modes 0 and 2 have the sign in the MSb.

Quoted 9 lines

Review static ssize_t show_temp(struct device * · line 1241

Quoted 5 lines
(quoted diff) +5 -0
+			sign = data->temp[nr]&  0x0001;
+		else
+			sign = data->temp[nr]&  0x8000;
+
+		temp = (data->temp[nr]>>  5)&  0x3ff;

This is only correct for modes 0 and 2. For modes 1 and 3, there are 11 bits of data, not 10, so the mask should be 0x7ff.

You are right on both accounts, both fixed.

<snip>

Quoted 11 lines

Review static int __devinit f71882fg_probe(stru · line 1879

Quoted 8 lines
(quoted diff) +4 -0
@@ -1773,6 +1873,12 @@ static int __devinit f71882fg_probe(stru
 
  		/* Sanity check the pwm settings */
  		switch (data->type) {
+		case f71858fg:
+			err = 0;
+			for (i = 0; i<  nr_fans; i++)
+				if (((data->pwm_enable>>  i * 2)&  3) == 3)

Ditto for parentheses.

Fixed for both occurences.

Updated version attached.

Regards,

Hans

hwmon: f71882fg add support for the f71858fg

Add support for the hwmon part of the Fintek f71858fg superio IC to the f71882fg driver. Many thanks to Jelle de Jong for lending me a motherboard with this superio on it.

Documentation/hwmon/f71882fg renamed from Documentation/hwmon/f71882fg.f71858fg +8 -4
diff -up vanilla-2.6.30-rc6-git2/Documentation/hwmon/f71882fg.f71858fg vanilla-2.6.30-rc6-git2/Documentation/hwmon/f71882fg
@@ -2,14 +2,18 @@ Kernel driver f71882fg
 ======================
 
 Supported chips:
-  * Fintek F71882FG and F71883FG
-    Prefix: 'f71882fg'
+  * Fintek F71858FG
+    Prefix: 'f71858fg'
     Addresses scanned: none, address read from Super I/O config space
     Datasheet: Available from the Fintek website
   * Fintek F71862FG and F71863FG
     Prefix: 'f71862fg'
     Addresses scanned: none, address read from Super I/O config space
     Datasheet: Available from the Fintek website
+  * Fintek F71882FG and F71883FG
+    Prefix: 'f71882fg'
+    Addresses scanned: none, address read from Super I/O config space
+    Datasheet: Available from the Fintek website
   * Fintek F8000
     Prefix: 'f8000'
     Addresses scanned: none, address read from Super I/O config space
@@ -66,13 +70,13 @@ printed when loading the driver.
 
 Three different fan control modes are supported; the mode number is written
 to the pwm#_enable file. Note that not all modes are supported on all
-chips, and some modes may only be available in RPM / PWM mode on the F8000.
+chips, and some modes may only be available in RPM / PWM mode.
 Writing an unsupported mode will result in an invalid parameter error.
 
 * 1: Manual mode
   You ask for a specific PWM duty cycle / DC voltage or a specific % of
   fan#_full_speed by writing to the pwm# file. This mode is only
-  available on the F8000 if the fan channel is in RPM mode.
+  available on the F71858FG / F8000 if the fan channel is in RPM mode.
 
 * 2: Normal auto mode
   You can define a number of temperature/fan speed trip points, which % the
drivers/hwmon/Kconfig renamed from drivers/hwmon/Kconfig.f71858fg +2 -2
diff -up vanilla-2.6.30-rc6-git2/drivers/hwmon/Kconfig.f71858fg vanilla-2.6.30-rc6-git2/drivers/hwmon/Kconfig
@@ -306,11 +306,11 @@ config SENSORS_F71805F
 	  will be called f71805f.
 
 config SENSORS_F71882FG
-	tristate "Fintek F71862FG, F71882FG and F8000"
+	tristate "Fintek F71858FG, F71862FG, F71882FG and F8000"
 	depends on EXPERIMENTAL
 	help
 	  If you say yes here you get support for hardware monitoring
-	  features of the Fintek F71882FG/F71883FG, F71862FG/71863FG
+	  features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG
 	  and F8000 Super-I/O chips.
 
 	  This driver can also be built as a module.  If so, the module
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +156 -36

363 lines not on this page · raw message

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

#3 lore raw
In reply to Hans de Goede
Quoted 78 lines · Hans de Goede
Quoted 11 lines · Jean Delvare

Hi Hans,

Quoted 5 lines · Hans de Goede

Add support for the hwmon part of the Fintek f71858fg superio IC to the f71882fg driver. Many thanks to Jelle de Jong for lending me a motherboard with this superio on it.

Review:

Many thanks for the quick review !

Quoted 6 lines
Quoted 6 lines

(...)
static struct f71882fg_data *f71882fg_update_device(struct device *dev) {
struct f71882fg_data *data = dev_get_drvdata(dev); int nr, reg = 0, reg2;
int nr_fans = (data->type = f71882fg) ? 4 : 3;

Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +2 -2
-	int nr_ins = (data->type = f8000) ? 3 : 9;
-	int temp_start = (data->type = f8000) ? 0 : 1;
+	int nr_ins = (data->type = f71858fg || data->type = f8000) ? 3 : 9;
+	int temp_start > >> +	    (data->type = f71858fg || data->type = f8000) ? 0 : 1;

It might be a good idea to add these values to struct f71882fg_data (maybe in a separate patch) so that you don't have to compute them every time. Especially temp_start is used in several functions.

I've done this for temp_start.

Quoted 17 lines

drivers/hwmon/f71882fg.c static ssize_t show_temp(struct device * · line 1236

Quoted 9 lines

(...)

drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +4 -0
@@ -1166,8 +1230,22 @@ static ssize_t show_temp(struct device *
  {
  	struct f71882fg_data *data = f71882fg_update_device(dev);
  	int nr = to_sensor_dev_attr_2(devattr)->index;
+	int sign, temp;
+
+	if (data->type = f71858fg) {
+		if ((data->temp_config&  3) = 3)

If I read the datasheet correctly, this should be:

		if ((data->temp_config&  1) = 1)

Both modes 1 and 3 have the sign in the LSb while modes 0 and 2 have the sign in the MSb.

Quoted 9 lines

Review static ssize_t show_temp(struct device * · line 1241

Quoted 5 lines
(quoted diff) +5 -0
+			sign = data->temp[nr]&  0x0001;
+		else
+			sign = data->temp[nr]&  0x8000;
+
+		temp = (data->temp[nr]>>  5)&  0x3ff;

This is only correct for modes 0 and 2. For modes 1 and 3, there are 11 bits of data, not 10, so the mask should be 0x7ff.

You are right on both accounts, both fixed.

<snip>

Quoted 11 lines

drivers/hwmon/f71882fg.c static int __devinit f71882fg_probe(stru · line 1879

Quoted 8 lines
drivers/hwmon/f71882fg.c renamed from drivers/hwmon/f71882fg.c.f71858fg +4 -0
@@ -1773,6 +1873,12 @@ static int __devinit f71882fg_probe(stru
 
  		/* Sanity check the pwm settings */
  		switch (data->type) {
+		case f71858fg:
+			err = 0;
+			for (i = 0; i<  nr_fans; i++)
+				if (((data->pwm_enable>>  i * 2)&  3) = 3)

Ditto for parentheses.

Quoted 3 lines

Fixed for both occurences.

Updated version attached.

Looks good this time, applied, thanks.

Signature · 6 lines
Jean Delvare

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