linux-mips
[Top] [All Lists]

Re: [PATCH] ar7: register watchdog driver only if enabled in hardware co

To: Alexander Clouter <alex@digriz.org.uk>
Subject: Re: [PATCH] ar7: register watchdog driver only if enabled in hardware configuration
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Date: Wed, 05 Aug 2009 12:19:07 +0400
Cc: linux-mips@linux-mips.org
In-reply-to: <62qmk6-g11.ln1@chipmunk.wormnet.eu>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <200908042309.36721.florian@openwrt.org> <62qmk6-g11.ln1@chipmunk.wormnet.eu>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)
Hello.

Alexander Clouter wrote:

This patch checks if the watchdog enable bit is set in the DCL
register meaning that the hardware watchdog actually works and
if so, register the ar7_wdt platform_device.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index e2278c0..835f3f0 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -503,6 +503,7 @@ static int __init ar7_register_devices(void)
{
       u16 chip_id;
       int res;
+       u32 *bootcr, val;
#ifdef CONFIG_SERIAL_8250
       static struct uart_port uart_port[2];

@@ -595,7 +596,13 @@ static int __init ar7_register_devices(void)

       ar7_wdt_res.end = ar7_wdt_res.start + 0x20;

-       res = platform_device_register(&ar7_wdt);
+       bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4);
+       val = *bootcr;
+       iounmap(bootcr);
+
+       /* Register watchdog only if enabled in hardware */
+       if (val & AR7_WDT_HW_ENA)
+               res = platform_device_register(&ar7_wdt);

I think the 'correct' way to do this is:
---
void __iomem *bootcr;
u32 val;

...

bootcr = ioremap_nocache(AR7_REGS_DCL, 4);
val = *bootcr;

 Wait, you can't dereference a pointer to void...

WBR, Sergei



<Prev in Thread] Current Thread [Next in Thread>