Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@mvista.com>
To: John Crispin <blogic@openwrt.org>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Ralph Hempel <ralph.hempel@lantiq.com>,
	Wim Van Sebroeck <wim@iguana.be>,
	linux-mips@linux-mips.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH V5 05/10] MIPS: lantiq: add watchdog support
Date: Thu, 07 Apr 2011 18:31:31 +0400	[thread overview]
Message-ID: <4D9DCAC3.9090607@mvista.com> (raw)
In-Reply-To: <1301470076-17279-6-git-send-email-blogic@openwrt.org>

Hello.

John Crispin wrote:

> This patch adds the driver for the watchdog found inside the Lantiq SoC family.

> Signed-off-by: John Crispin <blogic@openwrt.org>
> Signed-off-by: Ralph Hempel <ralph.hempel@lantiq.com>
> Cc: Wim Van Sebroeck <wim@iguana.be>
> Cc: linux-mips@linux-mips.org
> Cc: linux-watchdog@vger.kernel.org

> diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c
> new file mode 100644
> index 0000000..0a78dfb
> --- /dev/null
> +++ b/drivers/watchdog/lantiq_wdt.c
> @@ -0,0 +1,217 @@
[...]
> +/* Section 3.4 of the datasheet
> + * The password sequence protects the WDT control register from unintended
> + * write actions, which might cause malfunction of the WDT.
> + *
> + * essentially the following two magic passwords need to be written to allow
> + * io access to the wdt core

    s/io/IO/, s/wdt/WDT. Be consistent. :-)

> +static void
> +ltq_wdt_enable(unsigned int timeout)

    This function is always called with 'ltw_wdt_timeout' as a parameter. Seems 
better to use it internally, and not pass it every time.

> +{
> +	timeout = ((timeout * (ltq_io_region_clk_rate / LTQ_WDT_DIVIDER))
> +		+ 0x1000);

    The parens around rvalue are not needed.

[...]
> +static ssize_t
> +ltq_wdt_write(struct file *file, const char __user *data,
> +		size_t len, loff_t *ppos)
> +{
> +	size_t i;
> +
> +	if (!len)
> +		return 0;
> +#ifndef CONFIG_WATCHDOG_NOWAYOUT

    Er, Documentation/CodingStyle asks not to use #ifdef inside the code. You 
could create a special function here...

> +	for (i = 0; i != len; i++) {
> +		char c;
> +
> +		if (get_user(c, data + i))
> +			return -EFAULT;
> +		if (c == 'V')
> +			ltq_wdt_ok_to_close = 1;
> +	}
> +#endif
> +	ltq_wdt_enable(ltq_wdt_timeout);
> +	return len;
> +}

[...]

> +static int __init
> +ltq_wdt_probe(struct platform_device *pdev)
> +{
> +	struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	struct clk *clk;
> +
> +	if (!res) {
> +		dev_err(&pdev->dev, "cannot obtain I/O memory region");
> +		return -ENOENT;
> +	}
> +	res = devm_request_mem_region(&pdev->dev, res->start,
> +		resource_size(res), dev_name(&pdev->dev));
> +	if (!res) {
> +		dev_err(&pdev->dev, "cannot request I/O memory region");
> +		return -EBUSY;
> +	}
> +	ltq_wdt_membase = devm_ioremap_nocache(&pdev->dev, res->start,
> +		resource_size(res));
> +	if (!ltq_wdt_membase) {
> +		dev_err(&pdev->dev, "cannot remap I/O memory region\n");
> +		return -ENOMEM;
> +	}
> +	/* we do not need to enable the clock as it is always running */
> +	clk = clk_get(&pdev->dev, "io");
> +	BUG_ON(!clk);

    WARN_ON(). We shouldn't kill the whole machine I think.

> +static int __init
> +init_ltq_wdt(void)
> +{
> +	return platform_driver_probe(&ltq_wdt_driver, ltq_wdt_probe);
> +}
> +
> +module_init(init_ltq_wdt);

    How about module_exit()?

WBR, Sergei

  parent reply	other threads:[~2011-04-07 14:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-30  7:27 [PATCH V5 00/10] MIPS: lantiq: add initial support for Lantiq SoCs John Crispin
2011-03-30  7:27 ` [PATCH V5 01/10] " John Crispin
2011-03-31 13:01   ` Ralf Baechle
2011-03-31 13:35     ` John Crispin
2011-03-30  7:27 ` [PATCH V5 02/10] MIPS: lantiq: add SoC specific code for XWAY family John Crispin
2011-03-31 13:01   ` Ralf Baechle
2011-03-30  7:27 ` [PATCH V5 03/10] MIPS: lantiq: add PCI controller support John Crispin
2011-03-31 13:01   ` Ralf Baechle
2011-03-30  7:27 ` [PATCH V5 04/10] MIPS: lantiq: add serial port support John Crispin
2011-03-30  9:33   ` Alan Cox
2011-03-30  7:27 ` [PATCH V5 05/10] MIPS: lantiq: add watchdog support John Crispin
2011-03-30  9:36   ` Wim Van Sebroeck
2011-03-30  9:41     ` John Crispin
2011-04-07 14:31   ` Sergei Shtylyov [this message]
2011-03-30  7:27 ` [PATCH V5 06/10] MIPS: lantiq: add NOR flash support John Crispin
2011-04-01 12:43   ` Artem Bityutskiy
2011-04-04 13:36     ` John Crispin
2011-04-04 14:07       ` Artem Bityutskiy
2011-03-30  7:27 ` [PATCH V5 07/10] MIPS: lantiq: add platform device support John Crispin
2011-03-31 13:01   ` Ralf Baechle
2011-03-30  7:27 ` [PATCH V5 08/10] MIPS: lantiq: add mips_machine support John Crispin
2011-03-31 13:01   ` Ralf Baechle
2011-03-30  7:27 ` [PATCH V5 09/10] MIPS: lantiq: add machtypes for lantiq eval kits John Crispin
2011-03-31 13:02   ` Ralf Baechle
2011-03-30  7:27 ` [PATCH V5 10/10] MIPS: lantiq: add more gpio drivers John Crispin
2011-03-31 13:02   ` Ralf Baechle

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=4D9DCAC3.9090607@mvista.com \
    --to=sshtylyov@mvista.com \
    --cc=blogic@openwrt.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=ralph.hempel@lantiq.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