All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nat Gurumoorthy <natg@google.com>
To: Jean Delvare <khali@linux-fr.org>,
	Guenter Roeck <guenter.roeck@ericsson.com>,
	Wim Van Sebroeck <wim@iguana.be>,
	lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org
Cc: mikew@google.com, Nat Gurumoorthy <natg@google.com>
Subject: [PATCH v8 2/2] Use "request_muxed_region" in it87 hwmon drivers
Date: Fri,  6 May 2011 11:55:15 -0700	[thread overview]
Message-ID: <1304708115-10451-1-git-send-email-natg@google.com> (raw)
In-Reply-To: <1304707960-10178-1-git-send-email-natg@google.com>

02 - Chages to hwmon it87 driver to use "request_muxed_region"
Serialize access to the hardware by using "request_muxed_region" macro defined
by Alan Cox. Call to this macro will hold off the requestor if the resource is
currently busy. "superio_enter" will return an error if call to 
"request_muxed_region" fails. Rest of the code change is to ripple an error
return from superio_enter to the top level.

Signed-off-by: Nat Gurumoorthy <natg@google.com>
---

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 316b648..fa3ff02 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -108,13 +108,20 @@ superio_select(int ldn)
 	outb(ldn, VAL);
 }
 
-static inline void
+static inline int
 superio_enter(void)
 {
+	/*
+	 * Try to reserve REG and REG + 1 for exclusive access.
+	 */
+	if (!request_muxed_region(REG, 2, DRVNAME))
+		return -EBUSY;
+
 	outb(0x87, REG);
 	outb(0x01, REG);
 	outb(0x55, REG);
 	outb(0x55, REG);
+	return 0;
 }
 
 static inline void
@@ -122,6 +129,7 @@ superio_exit(void)
 {
 	outb(0x02, REG);
 	outb(0x02, VAL);
+	release_region(REG, 2);
 }
 
 /* Logical device 4 registers */
@@ -1546,7 +1554,9 @@ static int __init it87_find(unsigned short *address,
 	u16 chip_type;
 	const char *board_vendor, *board_name;
 
-	superio_enter();
+	if (superio_enter())
+		return -EBUSY;
+
 	chip_type = force_id ? force_id : superio_inw(DEVID);
 
 	switch (chip_type) {
-- 
1.7.3.1


WARNING: multiple messages have this Message-ID (diff)
From: Nat Gurumoorthy <natg@google.com>
To: Jean Delvare <khali@linux-fr.org>,
	Guenter Roeck <guenter.roeck@ericsson.com>,
	Wim Van Sebroeck <wim@iguana.be>,
	lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org
Cc: mikew@google.com, Nat Gurumoorthy <natg@google.com>
Subject: [lm-sensors] [PATCH v8 2/2] Use "request_muxed_region" in it87
Date: Fri, 06 May 2011 18:55:15 +0000	[thread overview]
Message-ID: <1304708115-10451-1-git-send-email-natg@google.com> (raw)
In-Reply-To: <1304707960-10178-1-git-send-email-natg@google.com>

02 - Chages to hwmon it87 driver to use "request_muxed_region"
Serialize access to the hardware by using "request_muxed_region" macro defined
by Alan Cox. Call to this macro will hold off the requestor if the resource is
currently busy. "superio_enter" will return an error if call to 
"request_muxed_region" fails. Rest of the code change is to ripple an error
return from superio_enter to the top level.

Signed-off-by: Nat Gurumoorthy <natg@google.com>
---

diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 316b648..fa3ff02 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -108,13 +108,20 @@ superio_select(int ldn)
 	outb(ldn, VAL);
 }
 
-static inline void
+static inline int
 superio_enter(void)
 {
+	/*
+	 * Try to reserve REG and REG + 1 for exclusive access.
+	 */
+	if (!request_muxed_region(REG, 2, DRVNAME))
+		return -EBUSY;
+
 	outb(0x87, REG);
 	outb(0x01, REG);
 	outb(0x55, REG);
 	outb(0x55, REG);
+	return 0;
 }
 
 static inline void
@@ -122,6 +129,7 @@ superio_exit(void)
 {
 	outb(0x02, REG);
 	outb(0x02, VAL);
+	release_region(REG, 2);
 }
 
 /* Logical device 4 registers */
@@ -1546,7 +1554,9 @@ static int __init it87_find(unsigned short *address,
 	u16 chip_type;
 	const char *board_vendor, *board_name;
 
-	superio_enter();
+	if (superio_enter())
+		return -EBUSY;
+
 	chip_type = force_id ? force_id : superio_inw(DEVID);
 
 	switch (chip_type) {
-- 
1.7.3.1


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2011-05-06 18:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-06 18:52 Nat Gurumoorthy
2011-05-06 18:52 ` [lm-sensors] (no subject) Nat Gurumoorthy
2011-05-06 18:54 ` [PATCH v8 1/2] Use "request_muxed_region" in it87 watchdog drivers Nat Gurumoorthy
2011-05-06 18:54   ` [lm-sensors] [PATCH v8 1/2] Use "request_muxed_region" in it87 Nat Gurumoorthy
2011-05-06 18:55 ` Nat Gurumoorthy [this message]
2011-05-06 18:55   ` [lm-sensors] [PATCH v8 2/2] " Nat Gurumoorthy
2011-05-06 19:13 ` Guenter Roeck
2011-05-06 19:13   ` [lm-sensors] (no subject) Guenter Roeck
2011-05-06 20:00   ` Natarajan Gurumoorthy
2011-05-06 20:00     ` [lm-sensors] (no subject) Natarajan Gurumoorthy
  -- strict thread matches above, loose matches on Subject: below --
2005-05-29 14:39 John WICKS
2008-09-23 13:29 ` gaming
2011-05-04  7:03 ` Jeremy Harmon
2011-05-10 18:53 ` Jeremy Harmon
2011-11-26 18:26 ` su_pyrow
2011-12-08 18:31 ` Guenter Roeck
2011-12-08 18:36 ` Guenter Roeck
2012-11-07 20:09 ` 郭�园
2012-12-04  7:22 ` Dok Sander
2013-08-23 23:53 ` Robert Hinson
2013-10-29 17:51 ` morgan chong

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=1304708115-10451-1-git-send-email-natg@google.com \
    --to=natg@google.com \
    --cc=guenter.roeck@ericsson.com \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=mikew@google.com \
    --cc=wim@iguana.be \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.