[kernel] r16358 - in dists/sid/linux-2.6/debian: . patches/features/all patches/series

Ben Hutchings benh at alioth.debian.org
Sun Sep 26 20:58:50 UTC 2010


Author: benh
Date: Sun Sep 26 20:58:47 2010
New Revision: 16358

Log:
f71882fg: Add support for the f71889fg (Closes: #597820)

Added:
   dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Add-support-for-the-f71889fg.patch
   dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-1-2.patch
   dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-2-2.patch
   dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Fix-sysfs-file-removal.patch
Modified:
   dists/sid/linux-2.6/debian/changelog
   dists/sid/linux-2.6/debian/patches/series/24

Modified: dists/sid/linux-2.6/debian/changelog
==============================================================================
--- dists/sid/linux-2.6/debian/changelog	Sun Sep 26 14:36:27 2010	(r16357)
+++ dists/sid/linux-2.6/debian/changelog	Sun Sep 26 20:58:47 2010	(r16358)
@@ -29,6 +29,7 @@
     - sctp: Do not reset the packet during sctp_packet_config()
       (CVE-2010-3432)
   * 3c59x: Remove incorrect locking (Closes: #598103)
+  * f71882fg: Add support for the f71889fg (Closes: #597820)
 
   [ Martin Michlmayr ]
   * ARM: update mach types.

Added: dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Add-support-for-the-f71889fg.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Add-support-for-the-f71889fg.patch	Sun Sep 26 20:58:47 2010	(r16358)
@@ -0,0 +1,286 @@
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Wed, 9 Dec 2009 20:36:01 +0100
+Subject: [PATCH 4/4] hwmon: (f71882fg) Add support for the f71889fg (version 2)
+
+commit 7669896f499e1bce5cfb38f2685ff583ecdb24dd upstream.
+
+This adds support for the Fintek f71889fg to the f71882fg driver,
+many thanks to Gerd v. Egidy for providing (remote) access to a
+machine which such an ic.
+
+Note that this bit of the patch:
+-	val = SENSORS_LIMIT(val, 0, 255);
++
++	if (data->type == f71889fg)
++		val = SENSORS_LIMIT(val, -128, 127);
++	else
++		val = SENSORS_LIMIT(val, 0, 127);
+
+Changes behaviour for already supported models, the new behaviour is correct
+as the already supported models have bit 7 of the involved registers fixed at
+0, so the previous behaviour which allowed setting temp zone limits > 127
+was not correct.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+Signed-off-by: Jean Delvare <khali at linux-fr.org>
+---
+ Documentation/hwmon/f71882fg |   10 +++++
+ drivers/hwmon/Kconfig        |    6 +-
+ drivers/hwmon/f71882fg.c     |   86 +++++++++++++++++++++++++++++++++---------
+ 3 files changed, 81 insertions(+), 21 deletions(-)
+
+diff --git a/Documentation/hwmon/f71882fg b/Documentation/hwmon/f71882fg
+index bee4c30..a7952c2 100644
+--- a/Documentation/hwmon/f71882fg
++++ b/Documentation/hwmon/f71882fg
+@@ -14,6 +14,10 @@ Supported chips:
+     Prefix: 'f71882fg'
+     Addresses scanned: none, address read from Super I/O config space
+     Datasheet: Available from the Fintek website
++  * Fintek F71889FG
++    Prefix: 'f71889fg'
++    Addresses scanned: none, address read from Super I/O config space
++    Datasheet: Should become available on the Fintek website soon
+   * Fintek F8000
+     Prefix: 'f8000'
+     Addresses scanned: none, address read from Super I/O config space
+@@ -51,6 +55,12 @@ supported. The right one to use depends on external circuitry on the
+ motherboard, so the driver assumes that the BIOS set the method
+ properly.
+ 
++Note that the lowest numbered temperature zone trip point corresponds to
++to the border between the highest and one but highest temperature zones, and
++vica versa. So the temperature zone trip points 1-4 (or 1-2) go from high temp
++to low temp! This is how things are implemented in the IC, and the driver
++mimicks this.
++
+ There are 2 modes to specify the speed of the fan, PWM duty cycle (or DC
+ voltage) mode, where 0-100% duty cycle (0-100% of 12V) is specified. And RPM
+ mode where the actual RPM of the fan (as measured) is controlled and the speed
+diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
+index dd69393..edf8feb 100644
+--- a/drivers/hwmon/Kconfig
++++ b/drivers/hwmon/Kconfig
+@@ -305,12 +305,12 @@ config SENSORS_F71805F
+ 	  will be called f71805f.
+ 
+ config SENSORS_F71882FG
+-	tristate "Fintek F71858FG, F71862FG, F71882FG and F8000"
++	tristate "Fintek F71858FG, F71862FG, F71882FG, F71889FG and F8000"
+ 	depends on EXPERIMENTAL
+ 	help
+ 	  If you say yes here you get support for hardware monitoring
+-	  features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG
+-	  and F8000 Super-I/O chips.
++	  features of the Fintek F71858FG, F71862FG/71863FG, F71882FG/F71883FG,
++	  F71889FG and F8000 Super-I/O chips.
+ 
+ 	  This driver can also be built as a module.  If so, the module
+ 	  will be called f71882fg.
+diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
+index 3a695f0..a95fa42 100644
+--- a/drivers/hwmon/f71882fg.c
++++ b/drivers/hwmon/f71882fg.c
+@@ -48,6 +48,7 @@
+ #define SIO_F71858_ID		0x0507  /* Chipset ID */
+ #define SIO_F71862_ID		0x0601	/* Chipset ID */
+ #define SIO_F71882_ID		0x0541	/* Chipset ID */
++#define SIO_F71889_ID		0x0723	/* Chipset ID */
+ #define SIO_F8000_ID		0x0581	/* Chipset ID */
+ 
+ #define REGION_LENGTH		8
+@@ -95,12 +96,13 @@ static unsigned short force_id;
+ module_param(force_id, ushort, 0);
+ MODULE_PARM_DESC(force_id, "Override the detected device ID");
+ 
+-enum chips { f71858fg, f71862fg, f71882fg, f8000 };
++enum chips { f71858fg, f71862fg, f71882fg, f71889fg, f8000 };
+ 
+ static const char *f71882fg_names[] = {
+ 	"f71858fg",
+ 	"f71862fg",
+ 	"f71882fg",
++	"f71889fg",
+ 	"f8000",
+ };
+ 
+@@ -155,7 +157,7 @@ struct f71882fg_data {
+ 	u8	pwm_auto_point_hyst[2];
+ 	u8	pwm_auto_point_mapping[4];
+ 	u8	pwm_auto_point_pwm[4][5];
+-	u8	pwm_auto_point_temp[4][4];
++	s8	pwm_auto_point_temp[4][4];
+ };
+ 
+ /* Sysfs in */
+@@ -945,7 +947,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev)
+ 	/* Update once every 60 seconds */
+ 	if ( time_after(jiffies, data->last_limits + 60 * HZ ) ||
+ 			!data->valid) {
+-		if (data->type == f71882fg) {
++		if (data->type == f71882fg || data->type == f71889fg) {
+ 			data->in1_max =
+ 				f71882fg_read8(data, F71882FG_REG_IN1_HIGH);
+ 			data->in_beep =
+@@ -967,7 +969,8 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev)
+ 						F71882FG_REG_TEMP_HYST(1));
+ 		}
+ 
+-		if (data->type == f71862fg || data->type == f71882fg) {
++		if (data->type == f71862fg || data->type == f71882fg ||
++		    data->type == f71889fg) {
+ 			data->fan_beep = f71882fg_read8(data,
+ 						F71882FG_REG_FAN_BEEP);
+ 			data->temp_beep = f71882fg_read8(data,
+@@ -977,15 +980,33 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev)
+ 			data->temp_type[2] = (reg & 0x04) ? 2 : 4;
+ 			data->temp_type[3] = (reg & 0x08) ? 2 : 4;
+ 		}
+-		reg2 = f71882fg_read8(data, F71882FG_REG_PECI);
+-		if ((reg2 & 0x03) == 0x01)
+-			data->temp_type[1] = 6 /* PECI */;
+-		else if ((reg2 & 0x03) == 0x02)
+-			data->temp_type[1] = 5 /* AMDSI */;
+-		else if (data->type == f71862fg || data->type == f71882fg)
+-			data->temp_type[1] = (reg & 0x02) ? 2 : 4;
+-		else
+-			data->temp_type[1] = 2; /* Only supports BJT */
++		/* Determine temp index 1 sensor type */
++		if (data->type == f71889fg) {
++			reg2 = f71882fg_read8(data, F71882FG_REG_START);
++			switch ((reg2 & 0x60) >> 5) {
++			case 0x00: /* BJT / Thermistor */
++				data->temp_type[1] = (reg & 0x02) ? 2 : 4;
++				break;
++			case 0x01: /* AMDSI */
++				data->temp_type[1] = 5;
++				break;
++			case 0x02: /* PECI */
++			case 0x03: /* Ibex Peak ?? Report as PECI for now */
++				data->temp_type[1] = 6;
++				break;
++			}
++		} else {
++			reg2 = f71882fg_read8(data, F71882FG_REG_PECI);
++			if ((reg2 & 0x03) == 0x01)
++				data->temp_type[1] = 6; /* PECI */
++			else if ((reg2 & 0x03) == 0x02)
++				data->temp_type[1] = 5; /* AMDSI */
++			else if (data->type == f71862fg ||
++				 data->type == f71882fg)
++				data->temp_type[1] = (reg & 0x02) ? 2 : 4;
++			else /* f71858fg and f8000 only support BJT */
++				data->temp_type[1] = 2;
++		}
+ 
+ 		data->pwm_enable = f71882fg_read8(data,
+ 						  F71882FG_REG_PWM_ENABLE);
+@@ -1062,7 +1083,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev)
+ 		if (data->type == f8000)
+ 			data->fan[3] = f71882fg_read16(data,
+ 						F71882FG_REG_FAN(3));
+-		if (data->type == f71882fg)
++		if (data->type == f71882fg || data->type == f71889fg)
+ 			data->in_status = f71882fg_read8(data,
+ 						F71882FG_REG_IN_STATUS);
+ 		for (nr = 0; nr < nr_ins; nr++)
+@@ -1780,7 +1801,11 @@ static ssize_t store_pwm_auto_point_temp(struct device *dev,
+ 	int pwm = to_sensor_dev_attr_2(devattr)->index;
+ 	int point = to_sensor_dev_attr_2(devattr)->nr;
+ 	long val = simple_strtol(buf, NULL, 10) / 1000;
+-	val = SENSORS_LIMIT(val, 0, 255);
++
++	if (data->type == f71889fg)
++		val = SENSORS_LIMIT(val, -128, 127);
++	else
++		val = SENSORS_LIMIT(val, 0, 127);
+ 
+ 	mutex_lock(&data->update_lock);
+ 	f71882fg_write8(data, F71882FG_REG_POINT_TEMP(pwm, point), val);
+@@ -1871,6 +1896,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 					ARRAY_SIZE(f71858fg_in_temp_attr));
+ 			break;
+ 		case f71882fg:
++		case f71889fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+ 					fxxxx_in1_alarm_attr,
+ 					ARRAY_SIZE(fxxxx_in1_alarm_attr));
+@@ -1908,6 +1934,7 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 			err = (data->pwm_enable & 0x15) != 0x15;
+ 			break;
+ 		case f71882fg:
++		case f71889fg:
+ 			err = 0;
+ 			break;
+ 		case f8000:
+@@ -1927,7 +1954,8 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 		if (err)
+ 			goto exit_unregister_sysfs;
+ 
+-		if (data->type == f71862fg || data->type == f71882fg) {
++		if (data->type == f71862fg || data->type == f71882fg ||
++		    data->type == f71889fg) {
+ 			err = f71882fg_create_sysfs_files(pdev,
+ 					fxxxx_fan_beep_attr, nr_fans);
+ 			if (err)
+@@ -1950,6 +1978,22 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 					f8000_auto_pwm_attr,
+ 					ARRAY_SIZE(f8000_auto_pwm_attr));
+ 			break;
++		case f71889fg:
++			for (i = 0; i < nr_fans; i++) {
++				data->pwm_auto_point_mapping[i] =
++					f71882fg_read8(data,
++						F71882FG_REG_POINT_MAPPING(i));
++				if (data->pwm_auto_point_mapping[i] & 0x80)
++					break;
++			}
++			if (i != nr_fans) {
++				dev_warn(&pdev->dev,
++					 "Auto pwm controlled by raw digital "
++					 "data, disabling pwm auto_point "
++					 "sysfs attributes\n");
++				break;
++			}
++			/* fall through */
+ 		default: /* f71858fg / f71882fg */
+ 			err = f71882fg_create_sysfs_files(pdev,
+ 				&fxxxx_auto_pwm_attr[0][0],
+@@ -2006,6 +2050,7 @@ static int f71882fg_remove(struct platform_device *pdev)
+ 					ARRAY_SIZE(f71858fg_in_temp_attr));
+ 			break;
+ 		case f71882fg:
++		case f71889fg:
+ 			f71882fg_remove_sysfs_files(pdev,
+ 					fxxxx_in1_alarm_attr,
+ 					ARRAY_SIZE(fxxxx_in1_alarm_attr));
+@@ -2027,7 +2072,8 @@ static int f71882fg_remove(struct platform_device *pdev)
+ 		f71882fg_remove_sysfs_files(pdev, &fxxxx_fan_attr[0][0],
+ 				ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans);
+ 
+-		if (data->type == f71862fg || data->type == f71882fg)
++		if (data->type == f71862fg || data->type == f71882fg ||
++		    data->type == f71889fg)
+ 			f71882fg_remove_sysfs_files(pdev,
+ 					fxxxx_fan_beep_attr, nr_fans);
+ 
+@@ -2082,11 +2128,15 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address,
+ 	case SIO_F71882_ID:
+ 		sio_data->type = f71882fg;
+ 		break;
++	case SIO_F71889_ID:
++		sio_data->type = f71889fg;
++		break;
+ 	case SIO_F8000_ID:
+ 		sio_data->type = f8000;
+ 		break;
+ 	default:
+-		printk(KERN_INFO DRVNAME ": Unsupported Fintek device\n");
++		printk(KERN_INFO DRVNAME ": Unsupported Fintek device: %04x\n",
++		       (unsigned int)devid);
+ 		goto exit;
+ 	}
+ 
+-- 
+1.7.1
+

Added: dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-1-2.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-1-2.patch	Sun Sep 26 20:58:47 2010	(r16358)
@@ -0,0 +1,341 @@
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Wed, 9 Dec 2009 20:35:59 +0100
+Subject: [PATCH 1/4] hwmon: (f71882fg) Cleanup sysfs attr creation 1/2
+
+commit 66344aa6adc4397f79f134ad122072dbe5abcb48 upstream.
+
+This patch makes a number of cleanups to the sysfs attr creation
+in the f71882fg driver, this is a preparation patch for adding f71889fg
+support:
+
+* Add some comments to explain why some models need separate sysfs attr
+  arrays for in / temp / fan / pwm
+* Rename a number of sysfs attr arrays to make their function clearer
+* Move the pwm#_auto_channels_temp attribute from the common to all
+  models fan attr array to the per model auto mode pwm attr arrays, so
+  that all the auto mode pwm attr are grouped together, and thus can be
+  left out on models where we don't support auto pwm mode
+* Put fan_beep attr in their own array, so that only auto mode pwm attr
+  remain in the per model pwm sysfs attr arrays.
+* Put the 4th special fan input for the f8000 in its own array, so that only
+  auto mode pwm attr remain in the per model pwm sysfs attr arrays.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+Signed-off-by: Jean Delvare <khali at linux-fr.org>
+---
+ drivers/hwmon/f71882fg.c |  137 ++++++++++++++++++++++++++++++----------------
+ 1 files changed, 89 insertions(+), 48 deletions(-)
+
+diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
+index 4146105..40dd6cf 100644
+--- a/drivers/hwmon/f71882fg.c
++++ b/drivers/hwmon/f71882fg.c
+@@ -258,7 +258,9 @@ static struct platform_driver f71882fg_driver = {
+ 
+ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+ 
+-/* Temp and in attr for the f71858fg */
++/* Temp and in attr for the f71858fg, the f71858fg is special as it
++   has its temperature indexes start at 0 (the others start at 1) and
++   it only has 3 voltage inputs */
+ static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = {
+ 	SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0),
+ 	SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1),
+@@ -302,8 +304,8 @@ static struct sensor_device_attribute_2 f71858fg_in_temp_attr[] = {
+ 	SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 2),
+ };
+ 
+-/* Temp and in attr common to both the f71862fg and f71882fg */
+-static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = {
++/* Temp and in attr common to the f71862fg, f71882fg and f71889fg */
++static struct sensor_device_attribute_2 fxxxx_in_temp_attr[] = {
+ 	SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0),
+ 	SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1),
+ 	SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2),
+@@ -371,8 +373,8 @@ static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = {
+ 	SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3),
+ };
+ 
+-/* Temp and in attr found only on the f71882fg */
+-static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = {
++/* For models with in1 alarm capability */
++static struct sensor_device_attribute_2 fxxxx_in1_alarm_attr[] = {
+ 	SENSOR_ATTR_2(in1_max, S_IRUGO|S_IWUSR, show_in_max, store_in_max,
+ 		0, 1),
+ 	SENSOR_ATTR_2(in1_beep, S_IRUGO|S_IWUSR, show_in_beep, store_in_beep,
+@@ -383,6 +385,7 @@ static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = {
+ /* Temp and in attr for the f8000
+    Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max)
+    is used as hysteresis value to clear alarms
++   Also like the f71858fg its temperature indexes start at 0
+  */
+ static struct sensor_device_attribute_2 f8000_in_temp_attr[] = {
+ 	SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0),
+@@ -435,39 +438,36 @@ static struct sensor_device_attribute_2 fxxxx_fan_attr[] = {
+ 		      store_pwm_enable, 0, 0),
+ 	SENSOR_ATTR_2(pwm1_interpolate, S_IRUGO|S_IWUSR,
+ 		      show_pwm_interpolate, store_pwm_interpolate, 0, 0),
+-	SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR,
+-		      show_pwm_auto_point_channel,
+-		      store_pwm_auto_point_channel, 0, 0),
+ 
+ 	SENSOR_ATTR_2(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 1),
+ 	SENSOR_ATTR_2(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+ 		      store_pwm_enable, 0, 1),
+ 	SENSOR_ATTR_2(pwm2_interpolate, S_IRUGO|S_IWUSR,
+ 		      show_pwm_interpolate, store_pwm_interpolate, 0, 1),
+-	SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR,
+-		      show_pwm_auto_point_channel,
+-		      store_pwm_auto_point_channel, 0, 1),
+ 
+ 	SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
+ 	SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+ 		      store_pwm_enable, 0, 2),
+ 	SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR,
+ 		      show_pwm_interpolate, store_pwm_interpolate, 0, 2),
+-	SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
+-		      show_pwm_auto_point_channel,
+-		      store_pwm_auto_point_channel, 0, 2),
+ };
+ 
+-/* Fan / PWM attr for the f71862fg, less pwms and less zones per pwm than the
+-   f71882fg */
+-static struct sensor_device_attribute_2 f71862fg_fan_attr[] = {
++/* Attr for models which can beep on Fan alarm */
++static struct sensor_device_attribute_2 fxxxx_fan_beep_attr[] = {
+ 	SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+ 		store_fan_beep, 0, 0),
+ 	SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+ 		store_fan_beep, 0, 1),
+ 	SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+ 		store_fan_beep, 0, 2),
++};
+ 
++/* PWM attr for the f71862fg, fewer pwms and fewer zones per pwm than the
++   f71858fg / f71882fg / f71889fg */
++static struct sensor_device_attribute_2 f71862fg_auto_pwm_attr[] = {
++	SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 0),
+ 	SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      1, 0),
+@@ -487,6 +487,9 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = {
+ 	SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 0),
+ 
++	SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 1),
+ 	SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      1, 1),
+@@ -506,6 +509,9 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = {
+ 	SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 1),
+ 
++	SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 2),
+ 	SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      1, 2),
+@@ -526,8 +532,11 @@ static struct sensor_device_attribute_2 f71862fg_fan_attr[] = {
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 2),
+ };
+ 
+-/* Fan / PWM attr common to both the f71882fg and f71858fg */
+-static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = {
++/* PWM attr common to the f71858fg, f71882fg and f71889fg */
++static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[] = {
++	SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 0),
+ 	SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      0, 0),
+@@ -566,6 +575,9 @@ static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = {
+ 	SENSOR_ATTR_2(pwm1_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 0),
+ 
++	SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 1),
+ 	SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      0, 1),
+@@ -604,6 +616,9 @@ static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = {
+ 	SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 1),
+ 
++	SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 2),
+ 	SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      0, 2),
+@@ -644,14 +659,7 @@ static struct sensor_device_attribute_2 f71882fg_f71858fg_fan_attr[] = {
+ };
+ 
+ /* Fan / PWM attr found on the f71882fg but not on the f71858fg */
+-static struct sensor_device_attribute_2 f71882fg_fan_attr[] = {
+-	SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+-		store_fan_beep, 0, 0),
+-	SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+-		store_fan_beep, 0, 1),
+-	SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+-		store_fan_beep, 0, 2),
+-
++static struct sensor_device_attribute_2 f71882fg_auto_pwm_attr[] = {
+ 	SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
+ 	SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR,
+ 		      show_fan_full_speed,
+@@ -707,12 +715,18 @@ static struct sensor_device_attribute_2 f71882fg_fan_attr[] = {
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 3),
+ };
+ 
+-/* Fan / PWM attr for the f8000, zones mapped to temp instead of to pwm!
+-   Also the register block at offset A0 maps to TEMP1 (so our temp2, as the
+-   F8000 starts counting temps at 0), B0 maps the TEMP2 and C0 maps to TEMP0 */
++/* Fan attr specific to the f8000 (4th fan input can only measure speed) */
+ static struct sensor_device_attribute_2 f8000_fan_attr[] = {
+ 	SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
++};
+ 
++/* PWM attr for the f8000, zones mapped to temp instead of to pwm!
++   Also the register block at offset A0 maps to TEMP1 (so our temp2, as the
++   F8000 starts counting temps at 0), B0 maps the TEMP2 and C0 maps to TEMP0 */
++static struct sensor_device_attribute_2 f8000_auto_pwm_attr[] = {
++	SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 0),
+ 	SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      0, 2),
+@@ -751,6 +765,9 @@ static struct sensor_device_attribute_2 f8000_fan_attr[] = {
+ 	SENSOR_ATTR_2(temp1_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 2),
+ 
++	SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 1),
+ 	SENSOR_ATTR_2(temp2_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      0, 0),
+@@ -789,6 +806,9 @@ static struct sensor_device_attribute_2 f8000_fan_attr[] = {
+ 	SENSOR_ATTR_2(temp2_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 0),
+ 
++	SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
++		      show_pwm_auto_point_channel,
++		      store_pwm_auto_point_channel, 0, 2),
+ 	SENSOR_ATTR_2(temp3_auto_point1_pwm, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
+ 		      0, 1),
+@@ -1847,15 +1867,15 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 			break;
+ 		case f71882fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+-					f71882fg_in_temp_attr,
+-					ARRAY_SIZE(f71882fg_in_temp_attr));
++					fxxxx_in1_alarm_attr,
++					ARRAY_SIZE(fxxxx_in1_alarm_attr));
+ 			if (err)
+ 				goto exit_unregister_sysfs;
+ 			/* fall through! */
+ 		case f71862fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+-					f718x2fg_in_temp_attr,
+-					ARRAY_SIZE(f718x2fg_in_temp_attr));
++					fxxxx_in_temp_attr,
++					ARRAY_SIZE(fxxxx_in_temp_attr));
+ 			break;
+ 		case f8000:
+ 			err = f71882fg_create_sysfs_files(pdev,
+@@ -1905,25 +1925,40 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 		switch (data->type) {
+ 		case f71862fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+-					f71862fg_fan_attr,
+-					ARRAY_SIZE(f71862fg_fan_attr));
++					fxxxx_fan_beep_attr,
++					ARRAY_SIZE(fxxxx_fan_beep_attr));
++			if (err)
++				goto exit_unregister_sysfs;
++			err = f71882fg_create_sysfs_files(pdev,
++					f71862fg_auto_pwm_attr,
++					ARRAY_SIZE(f71862fg_auto_pwm_attr));
+ 			break;
+ 		case f71882fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+-					f71882fg_fan_attr,
+-					ARRAY_SIZE(f71882fg_fan_attr));
++					fxxxx_fan_beep_attr,
++					ARRAY_SIZE(fxxxx_fan_beep_attr));
++			if (err)
++				goto exit_unregister_sysfs;
++			err = f71882fg_create_sysfs_files(pdev,
++					f71882fg_auto_pwm_attr,
++					ARRAY_SIZE(f71882fg_auto_pwm_attr));
+ 			if (err)
+ 				goto exit_unregister_sysfs;
+ 			/* fall through! */
+ 		case f71858fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+-					f71882fg_f71858fg_fan_attr,
+-					ARRAY_SIZE(f71882fg_f71858fg_fan_attr));
++					fxxxx_auto_pwm_attr,
++					ARRAY_SIZE(fxxxx_auto_pwm_attr));
+ 			break;
+ 		case f8000:
+ 			err = f71882fg_create_sysfs_files(pdev,
+ 					f8000_fan_attr,
+ 					ARRAY_SIZE(f8000_fan_attr));
++			if (err)
++				goto exit_unregister_sysfs;
++			err = f71882fg_create_sysfs_files(pdev,
++					f8000_auto_pwm_attr,
++					ARRAY_SIZE(f8000_auto_pwm_attr));
+ 			break;
+ 		}
+ 		if (err)
+@@ -1965,22 +2000,28 @@ static int f71882fg_remove(struct platform_device *pdev)
+ 	   below are supersets of the ones skipped. */
+ 	device_remove_file(&pdev->dev, &dev_attr_name);
+ 
+-	for (i = 0; i < ARRAY_SIZE(f718x2fg_in_temp_attr); i++)
++	for (i = 0; i < ARRAY_SIZE(fxxxx_in_temp_attr); i++)
+ 		device_remove_file(&pdev->dev,
+-					&f718x2fg_in_temp_attr[i].dev_attr);
++					&fxxxx_in_temp_attr[i].dev_attr);
+ 
+-	for (i = 0; i < ARRAY_SIZE(f71882fg_in_temp_attr); i++)
++	for (i = 0; i < ARRAY_SIZE(fxxxx_in1_alarm_attr); i++)
+ 		device_remove_file(&pdev->dev,
+-					&f71882fg_in_temp_attr[i].dev_attr);
++					&fxxxx_in1_alarm_attr[i].dev_attr);
+ 
+ 	for (i = 0; i < ARRAY_SIZE(fxxxx_fan_attr); i++)
+ 		device_remove_file(&pdev->dev, &fxxxx_fan_attr[i].dev_attr);
+ 
+-	for (i = 0; i < ARRAY_SIZE(f71882fg_fan_attr); i++)
+-		device_remove_file(&pdev->dev, &f71882fg_fan_attr[i].dev_attr);
++	for (i = 0; i < ARRAY_SIZE(fxxxx_fan_beep_attr); i++)
++		device_remove_file(&pdev->dev,
++				   &fxxxx_fan_beep_attr[i].dev_attr);
+ 
+-	for (i = 0; i < ARRAY_SIZE(f8000_fan_attr); i++)
+-		device_remove_file(&pdev->dev, &f8000_fan_attr[i].dev_attr);
++	for (i = 0; i < ARRAY_SIZE(f71882fg_auto_pwm_attr); i++)
++		device_remove_file(&pdev->dev,
++				   &f71882fg_auto_pwm_attr[i].dev_attr);
++
++	for (i = 0; i < ARRAY_SIZE(f8000_auto_pwm_attr); i++)
++		device_remove_file(&pdev->dev,
++				   &f8000_auto_pwm_attr[i].dev_attr);
+ 
+ 	kfree(data);
+ 
+-- 
+1.7.1
+

Added: dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-2-2.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-2-2.patch	Sun Sep 26 20:58:47 2010	(r16358)
@@ -0,0 +1,253 @@
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Wed, 9 Dec 2009 20:36:00 +0100
+Subject: [PATCH 2/4] hwmon: (f71882fg) Cleanup sysfs attr creation 2/2
+
+commit b69b039922673dfabe0b5774f2e313f2a2297d01 upstream.
+
+This patch merges the f71882fg_auto_pwm_attr array into the
+fxxxx_fan_attr resp. fxxxx_auto_pwm_attr array, as the f71882fg_auto_pwm_attr
+array was merely extending these 2 with entries for a 4th fan, it also makes
+these 2 arrays 2 dimensional so that the rest of the code can choose to
+add attr for 3 or 4 fans without needing to know the nr of attr per fan.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+Signed-off-by: Jean Delvare <khali at linux-fr.org>
+---
+ drivers/hwmon/f71882fg.c |  116 ++++++++++++++++++++-------------------------
+ 1 files changed, 52 insertions(+), 64 deletions(-)
+
+diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
+index 40dd6cf..210ed66 100644
+--- a/drivers/hwmon/f71882fg.c
++++ b/drivers/hwmon/f71882fg.c
+@@ -416,41 +416,51 @@ static struct sensor_device_attribute_2 f8000_in_temp_attr[] = {
+ };
+ 
+ /* Fan / PWM attr common to all models */
+-static struct sensor_device_attribute_2 fxxxx_fan_attr[] = {
++static struct sensor_device_attribute_2 fxxxx_fan_attr[4][6] = { {
+ 	SENSOR_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, 0),
+ 	SENSOR_ATTR_2(fan1_full_speed, S_IRUGO|S_IWUSR,
+ 		      show_fan_full_speed,
+ 		      store_fan_full_speed, 0, 0),
+ 	SENSOR_ATTR_2(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 0),
+-	SENSOR_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 0, 1),
+-	SENSOR_ATTR_2(fan2_full_speed, S_IRUGO|S_IWUSR,
+-		      show_fan_full_speed,
+-		      store_fan_full_speed, 0, 1),
+-	SENSOR_ATTR_2(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 1),
+-	SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2),
+-	SENSOR_ATTR_2(fan3_full_speed, S_IRUGO|S_IWUSR,
+-		      show_fan_full_speed,
+-		      store_fan_full_speed, 0, 2),
+-	SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2),
+-
+ 	SENSOR_ATTR_2(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 0),
+ 	SENSOR_ATTR_2(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+ 		      store_pwm_enable, 0, 0),
+ 	SENSOR_ATTR_2(pwm1_interpolate, S_IRUGO|S_IWUSR,
+ 		      show_pwm_interpolate, store_pwm_interpolate, 0, 0),
+-
++}, {
++	SENSOR_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 0, 1),
++	SENSOR_ATTR_2(fan2_full_speed, S_IRUGO|S_IWUSR,
++		      show_fan_full_speed,
++		      store_fan_full_speed, 0, 1),
++	SENSOR_ATTR_2(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 1),
+ 	SENSOR_ATTR_2(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 1),
+ 	SENSOR_ATTR_2(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+ 		      store_pwm_enable, 0, 1),
+ 	SENSOR_ATTR_2(pwm2_interpolate, S_IRUGO|S_IWUSR,
+ 		      show_pwm_interpolate, store_pwm_interpolate, 0, 1),
+-
++}, {
++	SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2),
++	SENSOR_ATTR_2(fan3_full_speed, S_IRUGO|S_IWUSR,
++		      show_fan_full_speed,
++		      store_fan_full_speed, 0, 2),
++	SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2),
+ 	SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
+ 	SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+ 		      store_pwm_enable, 0, 2),
+ 	SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR,
+ 		      show_pwm_interpolate, store_pwm_interpolate, 0, 2),
+-};
++}, {
++	SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
++	SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR,
++		      show_fan_full_speed,
++		      store_fan_full_speed, 0, 3),
++	SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3),
++	SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3),
++	SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
++		      store_pwm_enable, 0, 3),
++	SENSOR_ATTR_2(pwm4_interpolate, S_IRUGO|S_IWUSR,
++		      show_pwm_interpolate, store_pwm_interpolate, 0, 3),
++} };
+ 
+ /* Attr for models which can beep on Fan alarm */
+ static struct sensor_device_attribute_2 fxxxx_fan_beep_attr[] = {
+@@ -460,6 +470,8 @@ static struct sensor_device_attribute_2 fxxxx_fan_beep_attr[] = {
+ 		store_fan_beep, 0, 1),
+ 	SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+ 		store_fan_beep, 0, 2),
++	SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep,
++		store_fan_beep, 0, 3),
+ };
+ 
+ /* PWM attr for the f71862fg, fewer pwms and fewer zones per pwm than the
+@@ -533,7 +545,7 @@ static struct sensor_device_attribute_2 f71862fg_auto_pwm_attr[] = {
+ };
+ 
+ /* PWM attr common to the f71858fg, f71882fg and f71889fg */
+-static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[] = {
++static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[4][14] = { {
+ 	SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_channel,
+ 		      store_pwm_auto_point_channel, 0, 0),
+@@ -574,7 +586,7 @@ static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[] = {
+ 		      show_pwm_auto_point_temp_hyst, NULL, 2, 0),
+ 	SENSOR_ATTR_2(pwm1_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 0),
+-
++}, {
+ 	SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_channel,
+ 		      store_pwm_auto_point_channel, 0, 1),
+@@ -615,7 +627,7 @@ static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[] = {
+ 		      show_pwm_auto_point_temp_hyst, NULL, 2, 1),
+ 	SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 1),
+-
++}, {
+ 	SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_channel,
+ 		      store_pwm_auto_point_channel, 0, 2),
+@@ -656,23 +668,7 @@ static struct sensor_device_attribute_2 fxxxx_auto_pwm_attr[] = {
+ 		      show_pwm_auto_point_temp_hyst, NULL, 2, 2),
+ 	SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 2),
+-};
+-
+-/* Fan / PWM attr found on the f71882fg but not on the f71858fg */
+-static struct sensor_device_attribute_2 f71882fg_auto_pwm_attr[] = {
+-	SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
+-	SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR,
+-		      show_fan_full_speed,
+-		      store_fan_full_speed, 0, 3),
+-	SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep,
+-		store_fan_beep, 0, 3),
+-	SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3),
+-
+-	SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3),
+-	SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
+-		      store_pwm_enable, 0, 3),
+-	SENSOR_ATTR_2(pwm4_interpolate, S_IRUGO|S_IWUSR,
+-		      show_pwm_interpolate, store_pwm_interpolate, 0, 3),
++}, {
+ 	SENSOR_ATTR_2(pwm4_auto_channels_temp, S_IRUGO|S_IWUSR,
+ 		      show_pwm_auto_point_channel,
+ 		      store_pwm_auto_point_channel, 0, 3),
+@@ -713,7 +709,7 @@ static struct sensor_device_attribute_2 f71882fg_auto_pwm_attr[] = {
+ 		      show_pwm_auto_point_temp_hyst, NULL, 2, 3),
+ 	SENSOR_ATTR_2(pwm4_auto_point4_temp_hyst, S_IRUGO,
+ 		      show_pwm_auto_point_temp_hyst, NULL, 3, 3),
+-};
++} };
+ 
+ /* Fan attr specific to the f8000 (4th fan input can only measure speed) */
+ static struct sensor_device_attribute_2 f8000_fan_attr[] = {
+@@ -1917,39 +1913,24 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 			goto exit_unregister_sysfs;
+ 		}
+ 
+-		err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr,
+-					ARRAY_SIZE(fxxxx_fan_attr));
++		err = f71882fg_create_sysfs_files(pdev, &fxxxx_fan_attr[0][0],
++				ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans);
+ 		if (err)
+ 			goto exit_unregister_sysfs;
+ 
+-		switch (data->type) {
+-		case f71862fg:
++		if (data->type == f71862fg || data->type == f71882fg) {
+ 			err = f71882fg_create_sysfs_files(pdev,
+-					fxxxx_fan_beep_attr,
+-					ARRAY_SIZE(fxxxx_fan_beep_attr));
++					fxxxx_fan_beep_attr, nr_fans);
+ 			if (err)
+ 				goto exit_unregister_sysfs;
++		}
++
++		switch (data->type) {
++		case f71862fg:
+ 			err = f71882fg_create_sysfs_files(pdev,
+ 					f71862fg_auto_pwm_attr,
+ 					ARRAY_SIZE(f71862fg_auto_pwm_attr));
+ 			break;
+-		case f71882fg:
+-			err = f71882fg_create_sysfs_files(pdev,
+-					fxxxx_fan_beep_attr,
+-					ARRAY_SIZE(fxxxx_fan_beep_attr));
+-			if (err)
+-				goto exit_unregister_sysfs;
+-			err = f71882fg_create_sysfs_files(pdev,
+-					f71882fg_auto_pwm_attr,
+-					ARRAY_SIZE(f71882fg_auto_pwm_attr));
+-			if (err)
+-				goto exit_unregister_sysfs;
+-			/* fall through! */
+-		case f71858fg:
+-			err = f71882fg_create_sysfs_files(pdev,
+-					fxxxx_auto_pwm_attr,
+-					ARRAY_SIZE(fxxxx_auto_pwm_attr));
+-			break;
+ 		case f8000:
+ 			err = f71882fg_create_sysfs_files(pdev,
+ 					f8000_fan_attr,
+@@ -1960,6 +1941,10 @@ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ 					f8000_auto_pwm_attr,
+ 					ARRAY_SIZE(f8000_auto_pwm_attr));
+ 			break;
++		default: /* f71858fg / f71882fg */
++			err = f71882fg_create_sysfs_files(pdev,
++				&fxxxx_auto_pwm_attr[0][0],
++				ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans);
+ 		}
+ 		if (err)
+ 			goto exit_unregister_sysfs;
+@@ -1989,7 +1974,7 @@ exit_free:
+ 
+ static int f71882fg_remove(struct platform_device *pdev)
+ {
+-	int i;
++	int i, j;
+ 	struct f71882fg_data *data = platform_get_drvdata(pdev);
+ 
+ 	platform_set_drvdata(pdev, NULL);
+@@ -2009,15 +1994,18 @@ static int f71882fg_remove(struct platform_device *pdev)
+ 					&fxxxx_in1_alarm_attr[i].dev_attr);
+ 
+ 	for (i = 0; i < ARRAY_SIZE(fxxxx_fan_attr); i++)
+-		device_remove_file(&pdev->dev, &fxxxx_fan_attr[i].dev_attr);
++		for (j = 0; j < ARRAY_SIZE(fxxxx_fan_attr[0]); j++)
++			device_remove_file(&pdev->dev,
++					   &fxxxx_fan_attr[i][j].dev_attr);
+ 
+ 	for (i = 0; i < ARRAY_SIZE(fxxxx_fan_beep_attr); i++)
+ 		device_remove_file(&pdev->dev,
+ 				   &fxxxx_fan_beep_attr[i].dev_attr);
+ 
+-	for (i = 0; i < ARRAY_SIZE(f71882fg_auto_pwm_attr); i++)
+-		device_remove_file(&pdev->dev,
+-				   &f71882fg_auto_pwm_attr[i].dev_attr);
++	for (i = 0; i < ARRAY_SIZE(fxxxx_auto_pwm_attr); i++)
++		for (j = 0; j < ARRAY_SIZE(fxxxx_auto_pwm_attr[0]); j++)
++			device_remove_file(&pdev->dev,
++					  &fxxxx_auto_pwm_attr[i][j].dev_attr);
+ 
+ 	for (i = 0; i < ARRAY_SIZE(f8000_auto_pwm_attr); i++)
+ 		device_remove_file(&pdev->dev,
+-- 
+1.7.1
+

Added: dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Fix-sysfs-file-removal.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/sid/linux-2.6/debian/patches/features/all/hwmon-f71882fg-Fix-sysfs-file-removal.patch	Sun Sep 26 20:58:47 2010	(r16358)
@@ -0,0 +1,144 @@
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Wed, 9 Dec 2009 20:36:01 +0100
+Subject: [PATCH 3/4] hwmon: (f71882fg) Fix sysfs file removal
+
+commit fc16c56e694d361388bae701894fd719dbc0f7eb upstream.
+
+There is a bug in the old sysfs file removal, as it uses fxxxx_in_temp_attr
+to remove the in and temp sysfs attributes, but fxxxx_in_temp_attr has
+temp#_alarm, where as f71858fg_in_temp_attr has temp#_max_alarm, so
+the temp#_max_alarm attributes for the f71858fg never get removed.
+
+This patch fixes this by doing the sysfs removal exactly the same way as
+the creation instead of being (too) clever, this will also avoid similar
+bugs in the future.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+Signed-off-by: Jean Delvare <khali at linux-fr.org>
+---
+ drivers/hwmon/f71882fg.c |   91 +++++++++++++++++++++++++++++++++-------------
+ 1 files changed, 66 insertions(+), 25 deletions(-)
+
+diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
+index 210ed66..3a695f0 100644
+--- a/drivers/hwmon/f71882fg.c
++++ b/drivers/hwmon/f71882fg.c
+@@ -1810,6 +1810,15 @@ static int __devinit f71882fg_create_sysfs_files(struct platform_device *pdev,
+ 	return 0;
+ }
+ 
++static void f71882fg_remove_sysfs_files(struct platform_device *pdev,
++	struct sensor_device_attribute_2 *attr, int count)
++{
++	int i;
++
++	for (i = 0; i < count; i++)
++		device_remove_file(&pdev->dev, &attr[i].dev_attr);
++}
++
+ static int __devinit f71882fg_probe(struct platform_device *pdev)
+ {
+ 	struct f71882fg_data *data;
+@@ -1974,42 +1983,74 @@ exit_free:
+ 
+ static int f71882fg_remove(struct platform_device *pdev)
+ {
+-	int i, j;
+ 	struct f71882fg_data *data = platform_get_drvdata(pdev);
++	int nr_fans = (data->type == f71882fg) ? 4 : 3;
++	u8 start_reg = f71882fg_read8(data, F71882FG_REG_START);
+ 
+ 	platform_set_drvdata(pdev, NULL);
+ 	if (data->hwmon_dev)
+ 		hwmon_device_unregister(data->hwmon_dev);
+ 
+-	/* Note we are not looping over all attr arrays we have as the ones
+-	   below are supersets of the ones skipped. */
+ 	device_remove_file(&pdev->dev, &dev_attr_name);
+ 
+-	for (i = 0; i < ARRAY_SIZE(fxxxx_in_temp_attr); i++)
+-		device_remove_file(&pdev->dev,
+-					&fxxxx_in_temp_attr[i].dev_attr);
+-
+-	for (i = 0; i < ARRAY_SIZE(fxxxx_in1_alarm_attr); i++)
+-		device_remove_file(&pdev->dev,
+-					&fxxxx_in1_alarm_attr[i].dev_attr);
+-
+-	for (i = 0; i < ARRAY_SIZE(fxxxx_fan_attr); i++)
+-		for (j = 0; j < ARRAY_SIZE(fxxxx_fan_attr[0]); j++)
+-			device_remove_file(&pdev->dev,
+-					   &fxxxx_fan_attr[i][j].dev_attr);
++	if (start_reg & 0x01) {
++		switch (data->type) {
++		case f71858fg:
++			if (data->temp_config & 0x10)
++				f71882fg_remove_sysfs_files(pdev,
++					f8000_in_temp_attr,
++					ARRAY_SIZE(f8000_in_temp_attr));
++			else
++				f71882fg_remove_sysfs_files(pdev,
++					f71858fg_in_temp_attr,
++					ARRAY_SIZE(f71858fg_in_temp_attr));
++			break;
++		case f71882fg:
++			f71882fg_remove_sysfs_files(pdev,
++					fxxxx_in1_alarm_attr,
++					ARRAY_SIZE(fxxxx_in1_alarm_attr));
++			/* fall through! */
++		case f71862fg:
++			f71882fg_remove_sysfs_files(pdev,
++					fxxxx_in_temp_attr,
++					ARRAY_SIZE(fxxxx_in_temp_attr));
++			break;
++		case f8000:
++			f71882fg_remove_sysfs_files(pdev,
++					f8000_in_temp_attr,
++					ARRAY_SIZE(f8000_in_temp_attr));
++			break;
++		}
++	}
+ 
+-	for (i = 0; i < ARRAY_SIZE(fxxxx_fan_beep_attr); i++)
+-		device_remove_file(&pdev->dev,
+-				   &fxxxx_fan_beep_attr[i].dev_attr);
++	if (start_reg & 0x02) {
++		f71882fg_remove_sysfs_files(pdev, &fxxxx_fan_attr[0][0],
++				ARRAY_SIZE(fxxxx_fan_attr[0]) * nr_fans);
+ 
+-	for (i = 0; i < ARRAY_SIZE(fxxxx_auto_pwm_attr); i++)
+-		for (j = 0; j < ARRAY_SIZE(fxxxx_auto_pwm_attr[0]); j++)
+-			device_remove_file(&pdev->dev,
+-					  &fxxxx_auto_pwm_attr[i][j].dev_attr);
++		if (data->type == f71862fg || data->type == f71882fg)
++			f71882fg_remove_sysfs_files(pdev,
++					fxxxx_fan_beep_attr, nr_fans);
+ 
+-	for (i = 0; i < ARRAY_SIZE(f8000_auto_pwm_attr); i++)
+-		device_remove_file(&pdev->dev,
+-				   &f8000_auto_pwm_attr[i].dev_attr);
++		switch (data->type) {
++		case f71862fg:
++			f71882fg_remove_sysfs_files(pdev,
++					f71862fg_auto_pwm_attr,
++					ARRAY_SIZE(f71862fg_auto_pwm_attr));
++			break;
++		case f8000:
++			f71882fg_remove_sysfs_files(pdev,
++					f8000_fan_attr,
++					ARRAY_SIZE(f8000_fan_attr));
++			f71882fg_remove_sysfs_files(pdev,
++					f8000_auto_pwm_attr,
++					ARRAY_SIZE(f8000_auto_pwm_attr));
++			break;
++		default: /* f71858fg / f71882fg / f71889fg */
++			f71882fg_remove_sysfs_files(pdev,
++				&fxxxx_auto_pwm_attr[0][0],
++				ARRAY_SIZE(fxxxx_auto_pwm_attr[0]) * nr_fans);
++		}
++	}
+ 
+ 	kfree(data);
+ 
+-- 
+1.7.1
+

Modified: dists/sid/linux-2.6/debian/patches/series/24
==============================================================================
--- dists/sid/linux-2.6/debian/patches/series/24	Sun Sep 26 14:36:27 2010	(r16357)
+++ dists/sid/linux-2.6/debian/patches/series/24	Sun Sep 26 20:58:47 2010	(r16358)
@@ -64,3 +64,7 @@
 + debian/input-Avoid-ABI-change-from-compat-support.patch
 + debian/mm-Avoid-ABI-change-in-2.6.32.23.patch
 + bugfix/all/3c59x-Remove-incorrect-locking-correct-doc.patch
++ features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-1-2.patch
++ features/all/hwmon-f71882fg-Cleanup-sysfs-attr-creation-2-2.patch
++ features/all/hwmon-f71882fg-Fix-sysfs-file-removal.patch
++ features/all/hwmon-f71882fg-Add-support-for-the-f71889fg.patch



More information about the Kernel-svn-changes mailing list