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>
Cc: Mike Waychison <mikew@google.com>,
lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org, Nat Gurumoorthy <natg@google.com>
Subject: [PATCH 3/3] Make all it87 drivers SMP safe.
Date: Wed, 6 Apr 2011 14:13:16 -0700 [thread overview]
Message-ID: <1302124396-22449-1-git-send-email-natg@google.com> (raw)
03 - Adds changes to hwmon driver to use the new lock.
Signed-off-by: Nat Gurumoorthy <natg@google.com>
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 297bc9a..afe671a 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -436,6 +436,7 @@ config SENSORS_IBMPEX
config SENSORS_IT87
tristate "ITE IT87xx and compatibles"
select HWMON_VID
+ select IT87_LOCK
help
If you say yes here you get support for ITE IT8705F, IT8712F,
IT8716F, IT8718F, IT8720F, IT8721F, IT8726F and IT8758E sensor
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 316b648..bc32535 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -55,6 +55,8 @@
#include <linux/dmi.h>
#include <linux/acpi.h>
#include <linux/io.h>
+#include <linux/spinlock.h>
+#include <linux/it87_lock.h>
#define DRVNAME "it87"
@@ -110,7 +112,9 @@ superio_select(int ldn)
static inline void
superio_enter(void)
+__acquires(&it87_io_lock)
{
+ spin_lock(&it87_io_lock);
outb(0x87, REG);
outb(0x01, REG);
outb(0x55, REG);
@@ -119,9 +123,11 @@ superio_enter(void)
static inline void
superio_exit(void)
+__releases(&it87_io_lock)
{
outb(0x02, REG);
outb(0x02, VAL);
+ spin_unlock(&it87_io_lock);
}
/* Logical device 4 registers */
@@ -1899,8 +1905,12 @@ static int __devexit it87_remove(struct platform_device *pdev)
would slow down the IT87 access and should not be necessary. */
static int it87_read_value(struct it87_data *data, u8 reg)
{
+ int ret;
+ spin_lock(&it87_io_lock);
outb_p(reg, data->addr + IT87_ADDR_REG_OFFSET);
- return inb_p(data->addr + IT87_DATA_REG_OFFSET);
+ ret = inb_p(data->addr + IT87_DATA_REG_OFFSET);
+ spin_unlock(&it87_io_lock);
+ return ret;
}
/* Must be called with data->update_lock held, except during initialization.
@@ -1908,8 +1918,10 @@ static int it87_read_value(struct it87_data *data, u8 reg)
would slow down the IT87 access and should not be necessary. */
static void it87_write_value(struct it87_data *data, u8 reg, u8 value)
{
+ spin_lock(&it87_io_lock);
outb_p(reg, data->addr + IT87_ADDR_REG_OFFSET);
outb_p(value, data->addr + IT87_DATA_REG_OFFSET);
+ spin_unlock(&it87_io_lock);
}
/* Return 1 if and only if the PWM interface is safe to use */
--
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>
Cc: Mike Waychison <mikew@google.com>,
lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org, Nat Gurumoorthy <natg@google.com>
Subject: [lm-sensors] [PATCH 3/3] Make all it87 drivers SMP safe.
Date: Wed, 06 Apr 2011 21:13:16 +0000 [thread overview]
Message-ID: <1302124396-22449-1-git-send-email-natg@google.com> (raw)
03 - Adds changes to hwmon driver to use the new lock.
Signed-off-by: Nat Gurumoorthy <natg@google.com>
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 297bc9a..afe671a 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -436,6 +436,7 @@ config SENSORS_IBMPEX
config SENSORS_IT87
tristate "ITE IT87xx and compatibles"
select HWMON_VID
+ select IT87_LOCK
help
If you say yes here you get support for ITE IT8705F, IT8712F,
IT8716F, IT8718F, IT8720F, IT8721F, IT8726F and IT8758E sensor
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 316b648..bc32535 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -55,6 +55,8 @@
#include <linux/dmi.h>
#include <linux/acpi.h>
#include <linux/io.h>
+#include <linux/spinlock.h>
+#include <linux/it87_lock.h>
#define DRVNAME "it87"
@@ -110,7 +112,9 @@ superio_select(int ldn)
static inline void
superio_enter(void)
+__acquires(&it87_io_lock)
{
+ spin_lock(&it87_io_lock);
outb(0x87, REG);
outb(0x01, REG);
outb(0x55, REG);
@@ -119,9 +123,11 @@ superio_enter(void)
static inline void
superio_exit(void)
+__releases(&it87_io_lock)
{
outb(0x02, REG);
outb(0x02, VAL);
+ spin_unlock(&it87_io_lock);
}
/* Logical device 4 registers */
@@ -1899,8 +1905,12 @@ static int __devexit it87_remove(struct platform_device *pdev)
would slow down the IT87 access and should not be necessary. */
static int it87_read_value(struct it87_data *data, u8 reg)
{
+ int ret;
+ spin_lock(&it87_io_lock);
outb_p(reg, data->addr + IT87_ADDR_REG_OFFSET);
- return inb_p(data->addr + IT87_DATA_REG_OFFSET);
+ ret = inb_p(data->addr + IT87_DATA_REG_OFFSET);
+ spin_unlock(&it87_io_lock);
+ return ret;
}
/* Must be called with data->update_lock held, except during initialization.
@@ -1908,8 +1918,10 @@ static int it87_read_value(struct it87_data *data, u8 reg)
would slow down the IT87 access and should not be necessary. */
static void it87_write_value(struct it87_data *data, u8 reg, u8 value)
{
+ spin_lock(&it87_io_lock);
outb_p(reg, data->addr + IT87_ADDR_REG_OFFSET);
outb_p(value, data->addr + IT87_DATA_REG_OFFSET);
+ spin_unlock(&it87_io_lock);
}
/* Return 1 if and only if the PWM interface is safe to use */
--
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next reply other threads:[~2011-04-06 21:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 21:13 Nat Gurumoorthy [this message]
2011-04-06 21:13 ` [lm-sensors] [PATCH 3/3] Make all it87 drivers SMP safe Nat Gurumoorthy
2011-04-07 0:03 ` Guenter Roeck
2011-04-07 0:03 ` [lm-sensors] " Guenter Roeck
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=1302124396-22449-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=linux-watchdog@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.