lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1269385936-3440-3-git-send-email-me@mortis.eu>
Date:	Wed, 24 Mar 2010 00:12:15 +0100
From:	Giel van Schijndel <me@...tis.eu>
To:	Hans de Goede <hdegoede@...hat.com>
Cc:	Jean Delvare <khali@...ux-fr.org>,
	Giel van Schijndel <me@...tis.eu>,
	Jonathan Cameron <jic23@....ac.uk>,
	Laurens Leemans <laurens@...nips.com>,
	lm-sensors@...sensors.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/4] hwmon: f71882fg: add watchdog detection code

Factor out code for detecting the hardware monitor into a separate
function. Then add a function for detecting the watchdog.

Signed-off-by: Giel van Schijndel <me@...tis.eu>
---
 drivers/hwmon/f71882fg.c |   74 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 58 insertions(+), 16 deletions(-)

diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 7b31e14..8006271 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -2233,6 +2233,54 @@ static int f71882fg_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int __init f71882fg_find_watchdog(int sioaddr,
+	const struct f71882fg_sio_data *sio_data)
+{
+	switch (sio_data->type) {
+	case f71808fg:
+		break;
+
+	case f71862fg:
+	case f71882fg:
+	case f71889fg:
+		/* These have a watchdog, though it isn't implemented (yet). */
+		return -ENOSYS;
+
+	case f71858fg:
+	default:
+		/*
+		 * Confirmed (by datasheet) not to have a watchdog. That is,
+		 * except for chips matched by the 'default' label of course.
+		 */
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int __init f71882fg_find_hwmon(int sioaddr, unsigned short *hwmon_addr,
+	struct f71882fg_sio_data *sio_data)
+{
+	if (sio_data->type == f71858fg)
+		superio_select(sioaddr, SIO_F71858FG_LD_HWM);
+	else
+		superio_select(sioaddr, SIO_F71882FG_LD_HWM);
+
+	if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) {
+		printk(KERN_WARNING DRVNAME ": Device not activated\n");
+		return -ENODEV;
+	}
+
+	*hwmon_addr = superio_inw(sioaddr, SIO_REG_ADDR);
+	if (*hwmon_addr == 0) {
+		printk(KERN_WARNING DRVNAME ": Base address not set\n");
+		return -ENODEV;
+	}
+	*hwmon_addr &= ~(REGION_LENGTH - 1);	/* Ignore 3 LSB */
+
+	return 0;
+}
+
 static int __init f71882fg_find(int sioaddr, unsigned short *hwmon_addr,
 	struct f71882fg_sio_data *sio_data)
 {
@@ -2280,27 +2328,21 @@ static int __init f71882fg_find(int sioaddr, unsigned short *hwmon_addr,
 		goto exit;
 	}
 
-	if (sio_data->type == f71858fg)
-		superio_select(sioaddr, SIO_F71858FG_LD_HWM);
-	else
-		superio_select(sioaddr, SIO_F71882FG_LD_HWM);
-
-	if (!(superio_inb(sioaddr, SIO_REG_ENABLE) & 0x01)) {
-		printk(KERN_WARNING DRVNAME ": Device not activated\n");
-		goto exit;
-	}
-
-	*hwmon_addr = superio_inw(sioaddr, SIO_REG_ADDR);
-	if (*hwmon_addr == 0) {
-		printk(KERN_WARNING DRVNAME ": Base address not set\n");
+	err = f71882fg_find_hwmon(sioaddr, hwmon_addr, sio_data);
+	if (err)
 		goto exit;
-	}
-	*hwmon_addr &= ~(REGION_LENGTH - 1);	/* Ignore 3 LSB */
 
-	err = 0;
 	printk(KERN_INFO DRVNAME ": Found %s chip at %#x, revision %d\n",
 		f71882fg_names[sio_data->type],	(unsigned int)*hwmon_addr,
 		(int)superio_inb(sioaddr, SIO_REG_DEVREV));
+
+	err = f71882fg_find_watchdog(sioaddr, sio_data);
+	if (err == 0)
+		printk(KERN_INFO DRVNAME ": has supported watchdog\n");
+	else if (err != -ENODEV && err != -ENOSYS)
+		goto exit;
+
+	err = 0;
 exit:
 	superio_exit(sioaddr);
 	release_region(sioaddr, 2);
-- 
1.6.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ