From: Guenter Roeck <guenter.roeck@ericsson.com>
To: Nat Gurumoorthy <natg@google.com>
Cc: Jean Delvare <khali@linux-fr.org>,
Wim Van Sebroeck <wim@iguana.be>,
Mike Waychison <mikew@google.com>,
"lm-sensors@lm-sensors.org" <lm-sensors@lm-sensors.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-watchdog@vger.kernel.org" <linux-watchdog@vger.kernel.org>
Subject: Re: [PATCH v6 1/2] Use "request_muxed_region" in it87 watchdog drivers
Date: Thu, 14 Apr 2011 15:49:30 -0700 [thread overview]
Message-ID: <1302821370.26780.585.camel@groeck-laptop> (raw)
In-Reply-To: <1302817069-6389-1-git-send-email-natg@google.com>
On Thu, 2011-04-14 at 17:37 -0400, Nat Gurumoorthy wrote:
> 01 - Changes to it87 watchdog 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. The first call to request_muxed_region will attempt 10 times
> to reserve the region before it gives up. This will typically get called from
> the driver init routines. If this succeeds then subsequent calls wait forever
> for the resource to be available.
>
> The use of the above macro makes it possible to get rid of
> spinlocks in it8712f_wdt.c and it87_wdt.c watchdog drivers.
> This also greatly simplifies the implementation of it87_wdt.c driver.
>
> Signed-off-by: Nat Gurumoorthy <natg@google.com>
> ---
>
> diff --git a/drivers/watchdog/it8712f_wdt.c b/drivers/watchdog/it8712f_wdt.c
> index 6143f52..8bf2524 100644
> --- a/drivers/watchdog/it8712f_wdt.c
> +++ b/drivers/watchdog/it8712f_wdt.c
> @@ -51,7 +51,6 @@ MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
>
> static unsigned long wdt_open;
> static unsigned expect_close;
> -static spinlock_t io_lock;
> static unsigned char revision;
>
> /* Dog Food address - We use the game port address */
> @@ -121,9 +120,46 @@ static inline void superio_select(int ldn)
> outb(ldn, VAL);
> }
>
> -static inline void superio_enter(void)
> +static inline int
> +try_superio_enter(void)
> {
> - spin_lock(&io_lock);
> + int num_tries = 10;
> + /*
> + * Try to reserve REG and REG + 1 for exclusive access.
> + * Give up after 10 attempts.
> + */
> + while (num_tries--) {
> + if (!request_muxed_region(REG, 2, NAME)) {
> + if (num_tries)
> + continue;
> +
> + /*
> + * Someone is holding the region. Give up.
> + */
> + pr_err("I/O address 0x%04x already in use\n", REG);
> + return -EBUSY;
> + }
> +
> + break;
> + }
> +
This is way too complicated. Just return an error if
request_muxed_region fails, like all other callers of
request_muxed_region do.
Guenter
next prev parent reply other threads:[~2011-04-14 22:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-14 21:36 [PATCH v6 0/2] Make all it87 drivers SMP safe Nat Gurumoorthy
2011-04-14 21:37 ` [PATCH v6 1/2] Use "request_muxed_region" in it87 watchdog drivers Nat Gurumoorthy
2011-04-14 22:49 ` Guenter Roeck [this message]
2011-04-15 1:18 ` Natarajan Gurumoorthy
2011-04-15 2:40 ` Guenter Roeck
2011-04-15 3:14 ` Natarajan Gurumoorthy
2011-04-15 5:58 ` Guenter Roeck
2011-04-15 8:46 ` Natarajan Gurumoorthy
2011-04-15 11:05 ` Guenter Roeck
2011-04-18 7:33 ` [lm-sensors] " Hans de Goede
2011-04-14 21:38 ` [PATCH v6 2/2] Use "request_muxed_region" in it87 hwmon drivers Nat Gurumoorthy
2011-04-15 21:07 ` [PATCH v6 0/2] Make all it87 drivers SMP safe Jarod Wilson
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=1302821370.26780.585.camel@groeck-laptop \
--to=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=natg@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®