add SBC-FITPC2 watchdog driver
PATCH v2 1/1 add SBC-FITPC2 watchdog driver
Quoted 1 line
From: Denis Turischev <[email protected]>
This patch adds support for watchdog found on SBC-FITPC2 board.
--
v2 changes:
- reorder fitpc2_wdt_write to reduce the indent
- change printk levels
- use pr_fmt
- add release_region in the _init error path
drivers/watchdog/Kconfig +22 -0
@@ -721,6 +721,28 @@ To compile this driver as a module, choose M here: the module will be called sbc_epx_c3. +config SBC_FITPC2_WATCHDOG + tristate "Compulab SBC-FITPC2 watchdog" + depends on X86 + ---help--- + This is the driver for the built-in watchdog timer on the fit-PC2 + Single-board computer made by Compulab. + + It`s possible to enable watchdog timer either from BIOS (F2) or from booted Linux. + When "Watchdog Timer Value" enabled one can set 31-255 s operational range. + + Entering BIOS setup temporary disables watchdog operation regardless to current state, + so system will not be restarted while user in BIOS setup. + + Once watchdog was enabled the system will be restarted every + "Watchdog Timer Value" period, so to prevent it user can restart or + disable the watchdog. + + To compile this driver as a module, choose M here: the + module will be called sbc_fitpc2_wdt. + + Most people will say N. + # M32R Architecture # M68K Architecture
drivers/watchdog/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o obj-$(CONFIG_MACHZ_WDT) += machzwd.o obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o +obj-$(CONFIG_SBC_FITPC2_WATCHDOG) += sbc_fitpc2_wdt.o # M32R Architecture
drivers/watchdog/sbc_fitpc2_wdt.c +259 -0
259 lines not on this page · raw message
Signature · 2 lines
Sincerely yours, Mike.
Quoted 29 lines · On Tue, 21 Jul 2009 13:13:29 +0300 Mike Rapoport <[email protected]> wrote:
Quoted 1 line
From: Denis Turischev <[email protected]>
This patch adds support for watchdog found on SBC-FITPC2 board.
(quoted diff) +25
-0+/* + * Watchdog driver for SBC-FITPC2 board + * + * Author: Denis Turischev <[email protected]> + * + * Adapted from the IXP2000 watchdog driver by Deepak Saxena. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME " WATCHDOG: " fmt + +#include <linux/module.h> +#include <linux/types.h> +#include <linux/miscdevice.h> +#include <linux/watchdog.h> +#include <linux/ioport.h> +#include <linux/delay.h> +#include <linux/notifier.h> +#include <linux/fs.h> +#include <linux/reboot.h> +#include <linux/init.h> +#include <linux/moduleparam.h>
Review
Quoted 10 lines
(quoted diff) +10
-0+#include <linux/dmi.h> + +#include <linux/io.h> +#include <linux/uaccess.h> +#include <asm/system.h> + +static int nowayout = WATCHDOG_NOWAYOUT; +static unsigned int margin = 60; /* (secs) Default is 1 minute */ +static unsigned long wdt_status; +static spinlock_t wdt_lock;
You forgot to initialise the spinlock.
drivers/watchdog/sbc_fitpc2_wdt.c renamed from drivers/watchdog/sbc_fitpc2_wdt.c~watchdog-add-sbc-fitpc2-watchdog-driver-fix +1 -1
@@ -32,7 +32,7 @@static int nowayout =WATCHDOG_NOWAYOUT ;static unsigned int margin =60 ;/* (secs) Default is 1 minute */ static unsigned long wdt_status; -static spinlock_t wdt_lock; +static DEFINE_SPINLOCK (wdt_lock);#define WDT_IN_USE 0#define WDT_OK_TO_CLOSE 1
_
Hi Mike, Denis,
Quoted 11 lines
Quoted 1 line
From: Denis Turischev <[email protected]>
This patch adds support for watchdog found on SBC-FITPC2 board.
--
v2 changes:
- reorderfitpc2_wdt_writeto reduce the indent
- change printk levels
- usepr_fmt
- addrelease_regionin the_initerror path
Quoted 2 lines
Signed-off-by Denis Turischev <[email protected]>Signed-off-by Mike Rapoport <[email protected]>
Some remarks:
1) If you dou request_regions in the init section then you need to do release_regions also in the exit section.
2) we prefer:
static long wdt_ioctl(parameters
rest_of_parameters)
instead of
static long
wdt_ioctl(parameters)
3) misc_deregister can return with an error. If it does you need to do the release_regions also.
4) as Andrew allready pointed out spinlock needs to be initialized.
5) if you don't use the reboot_notifier then you don't need to include linux/notifier.h and linux/reboot.h .
I adapted the code.
Can you test the attached diff?
Thanks in advance,
Wim.
drivers/watchdog/Kconfig +22 -0
@@ -369,6 +369,28 @@ config SC520_WDT You can compile this driver directly into the kernel, or use it as a module. The module will be called sc520_wdt. +config SBC_FITPC2_WATCHDOG + tristate "Compulab SBC-FITPC2 watchdog" + depends on X86 + ---help--- + This is the driver for the built-in watchdog timer on the fit-PC2 + Single-board computer made by Compulab. + + It`s possible to enable watchdog timer either from BIOS (F2) or from booted Linux. + When "Watchdog Timer Value" enabled one can set 31-255 s operational range. + + Entering BIOS setup temporary disables watchdog operation regardless to current state, + so system will not be restarted while user in BIOS setup. + + Once watchdog was enabled the system will be restarted every + "Watchdog Timer Value" period, so to prevent it user can restart or + disable the watchdog. + + To compile this driver as a module, choose M here: the + module will be called sbc_fitpc2_wdt. + + Most people will say N. + config EUROTECH_WDT tristate "Eurotech CPU-1220/1410 Watchdog Timer" depends on X86
drivers/watchdog/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o obj-$(CONFIG_GEODE_WDT) += geodewdt.o obj-$(CONFIG_SC520_WDT) += sc520_wdt.o +obj-$(CONFIG_SBC_FITPC2_WATCHDOG) += sbc_fitpc2_wdt.o obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o obj-$(CONFIG_IB700_WDT) += ib700wdt.o obj-$(CONFIG_IBMASR) += ibmasr.o
drivers/watchdog/sbc_fitpc2_wdt.c new file +267 -0
267 lines not on this page · raw message
Thanks Wim,
Tested, seems ok.
Denis
Quoted 37 lines · Wim Van Sebroeck
Hi Mike, Denis,
Quoted 11 lines
Quoted 2 lines
From: Denis Turischev <[email protected]>
This patch adds support for watchdog found on SBC-FITPC2 board.
--
v2 changes:
- reorderfitpc2_wdt_writeto reduce the indent
- change printk levels
- usepr_fmt
- addrelease_regionin the_initerror pathQuoted 3 lines
Signed-off-by Denis Turischev <[email protected]>Signed-off-by Mike Rapoport <[email protected]>Some remarks:
1) If you dourequest_regionsin the init section then you need to dorelease_regionsalso in the exit section.
2) we prefer:
static long wdt_ioctl(parameters
rest_of_parameters)
instead of
static long
wdt_ioctl(parameters)
3)misc_deregistercan return with an error. If it does you need to do therelease_regionsalso.
4) as Andrew allready pointed out spinlock needs to be initialized.
5) if you don't use thereboot_notifierthen you don't need to includelinux/notifier.handlinux/reboot.h.I adapted the code.
Can you test the attached diff?Thanks in advance,
Wim.