mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: dsaxena@plexity.net
Cc: Andrew Morton <akpm@osdl.org>,
	wim@iguana.be, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6] Watchdog timer for Intel IXP4xx CPUs
Date: Tue, 11 May 2004 18:37:32 -0400	[thread overview]
Message-ID: <40A155AC.5090009@pobox.com> (raw)
In-Reply-To: <20040511215008.GA8063@plexity.net>

Deepak Saxena wrote:
> On May 11 2004, at 14:33, Andrew Morton was caught saying:
> +#ifdef CONFIG_WATCHDOG_NOWAYOUT
> +static int nowayout = 1;
> +#else
> +static int nowayout = 0;
> +#endif
> +static int heartbeat = 60;	/* (secs) Default is 1 minute */
> +static unsigned long wdt_status = 0;	
> +static unsigned long boot_status = 0;

Wastes bss(?) space to explicitly zero statics.


> +#define WDT_TICK_RATE (IXP4XX_PERIPHERAL_BUS_CLOCK * 1000000UL)
> +
> +#define	WDT_IN_USE		0
> +#define	WDT_OK_TO_CLOSE		1
> +
> +static void
> +wdt_enable(void)
> +{
> +	*IXP4XX_OSWK = IXP4XX_WDT_KEY;
> +	*IXP4XX_OSWE = 0;
> +	*IXP4XX_OSWT = WDT_TICK_RATE * heartbeat;
> +	*IXP4XX_OSWE = IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE;
> +	*IXP4XX_OSWK = 0;
> +}
> +
> +static void 
> +wdt_disable(void)
> +{
> +	*IXP4XX_OSWK = IXP4XX_WDT_KEY;
> +	*IXP4XX_OSWE = 0;
> +	*IXP4XX_OSWK = 0;
> +}

Are these magic CPU addresses you're writing to?  Normally one uses bus 
macros to read/write to devices.  But SoC and embedded stuff is often 
special...


> +static int
> +ixp4xx_wdt_open(struct inode *inode, struct file *file)
> +{
> +	if (test_and_set_bit(WDT_IN_USE, &wdt_status))
> +		return -EBUSY;
> +
> +	clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
> +
> +	wdt_enable();
> +
> +	return 0;
> +}

You typically want semaphores rather than bit tests.

And what about blocking on multiple openers?


> +static ssize_t 
> +ixp4xx_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
> +{
> +	/* Can't seek (pwrite) on this device  */
> +	if (ppos != &file->f_pos)
> +		return -ESPIPE;
> +
> +	if (len) {
> +		if (!nowayout) {
> +			size_t i;
> +
> +			clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
> +
> +			for (i = 0; i != len; i++) {
> +				char c;
> +
> +				if (get_user(c, data + i))
> +					return -EFAULT;
> +				if (c == 'V')
> +					set_bit(WDT_OK_TO_CLOSE, &wdt_status);
> +			}
> +		}
> +		wdt_enable();
> +	}

do other watchdog drivers really twiddle a bit like this on each write?

Otherwise looks OK.

	Jeff




  reply	other threads:[~2004-05-11 22:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-11 21:22 Deepak Saxena
2004-05-11 21:33 ` Andrew Morton
2004-05-11 21:50   ` Deepak Saxena
2004-05-11 22:37     ` Jeff Garzik [this message]
2004-05-11 22:48       ` Marc Singer
2004-05-11 23:02       ` Deepak Saxena

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=40A155AC.5090009@pobox.com \
    --to=jgarzik@pobox.com \
    --cc=akpm@osdl.org \
    --cc=dsaxena@plexity.net \
    --cc=linux-kernel@vger.kernel.org \
    --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®