public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, linux-usb-devel@lists.sourceforge.net
Cc: khali@linux-fr.org
Subject: [PATCH] hwmon: w83792d fix unused fan pins
Date: Tue, 29 Nov 2005 21:58:37 -0800	[thread overview]
Message-ID: <11333303173652@kroah.com> (raw)
In-Reply-To: <1133330317815@kroah.com>

[PATCH] hwmon: w83792d fix unused fan pins

1. This patch add check for fan4,5,6,7 and do not create device file
   if their pins are not configured as fan.
2. Fix the issue that can not set fan divisor to 128.
3. Fix the index out of bounds bug in w83792d_detect function.

Signed-off-by: Yuan Mu <ymu@winbond.com.tw>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit 9632051963cb6e6f7412990f8b962209b9334e13
tree 1f1fe030107d06e4b43dbee90e95b374ccec7fc2
parent d2ef5ebb4c4fe141a82252d4db8d8521e6765c5a
author Jean Delvare <khali@linux-fr.org> Tue, 29 Nov 2005 22:27:14 +0100
committer Greg Kroah-Hartman <gregkh@suse.de> Tue, 29 Nov 2005 21:39:22 -0800

 drivers/hwmon/w83792d.c |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 4be59db..1ba0726 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -193,6 +193,7 @@ static const u8 W83792D_REG_LEVELS[3][4]
 	  0xE2 }	/* (bit3-0) SmartFanII: Fan3 Level 3 */
 };
 
+#define W83792D_REG_GPIO_EN		0x1A
 #define W83792D_REG_CONFIG		0x40
 #define W83792D_REG_VID_FANDIV		0x47
 #define W83792D_REG_CHIPID		0x49
@@ -257,7 +258,7 @@ DIV_TO_REG(long val)
 {
 	int i;
 	val = SENSORS_LIMIT(val, 1, 128) >> 1;
-	for (i = 0; i < 6; i++) {
+	for (i = 0; i < 7; i++) {
 		if (val == 0)
 			break;
 		val >>= 1;
@@ -1282,8 +1283,8 @@ w83792d_detect(struct i2c_adapter *adapt
 	w83792d_init_client(new_client);
 
 	/* A few vars need to be filled upon startup */
-	for (i = 1; i <= 7; i++) {
-		data->fan_min[i - 1] = w83792d_read_value(new_client,
+	for (i = 0; i < 7; i++) {
+		data->fan_min[i] = w83792d_read_value(new_client,
 					W83792D_REG_FAN_MIN[i]);
 	}
 
@@ -1306,10 +1307,20 @@ w83792d_detect(struct i2c_adapter *adapt
 	device_create_file_fan(new_client, 1);
 	device_create_file_fan(new_client, 2);
 	device_create_file_fan(new_client, 3);
-	device_create_file_fan(new_client, 4);
-	device_create_file_fan(new_client, 5);
-	device_create_file_fan(new_client, 6);
-	device_create_file_fan(new_client, 7);
+
+	/* Read GPIO enable register to check if pins for fan 4,5 are used as
+	   GPIO */
+	val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN);
+	if (!(val1 & 0x40))
+		device_create_file_fan(new_client, 4);
+	if (!(val1 & 0x20))
+		device_create_file_fan(new_client, 5);
+
+	val1 = w83792d_read_value(new_client, W83792D_REG_PIN);
+	if (val1 & 0x40)
+		device_create_file_fan(new_client, 6);
+	if (val1 & 0x04)
+		device_create_file_fan(new_client, 7);
 
 	device_create_file_temp1(new_client);		/* Temp1 */
 	device_create_file_temp_add(new_client, 2);	/* Temp2 */


  reply	other threads:[~2005-11-30  5:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-30  5:56 [GIT PATCH] USB patches for 2.6.15-rc3 Greg KH
2005-11-30  5:58 ` [PATCH] USB: documentation update Greg KH
2005-11-30  5:58   ` Greg KH [this message]
2005-11-30  5:58     ` [PATCH] pci_ids.h: remove duplicate entries Greg KH
2005-11-30  5:58       ` [PATCH] Additional device ID for Conexant AccessRunner USB driver Greg KH
2005-11-30  5:58         ` [PATCH] USB: ehci fixups Greg KH
2005-11-30  5:58           ` [PATCH] USB: Fix USB suspend/resume crasher (#2) Greg KH
2005-11-30  8:09         ` [linux-usb-devel] [PATCH] Additional device ID for Conexant AccessRunner USB driver Duncan Sands
2005-11-30 22:30           ` Greg KH
2005-12-01  7:50             ` Duncan Sands
2005-11-30 18:23 ` [GIT PATCH] USB patches for 2.6.15-rc3 Linus Torvalds
2005-11-30 19:35   ` Greg KH
2005-11-30 20:35     ` Grant Coady
2005-12-01  4:10     ` (no subject) Glenn L Shurson
2005-11-30 19:39 ` [GIT PATCH] USB patches for 2.6.15-rc3 Jean Delvare

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11333303173652@kroah.com \
    --to=gregkh@suse.de \
    --cc=greg@kroah.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox