cregit-Linux how code gets into the kernel

Release 4.8 drivers/watchdog/softdog.c

Directory: drivers/watchdog
/*
 *      SoftDog:        A Software Watchdog Device
 *
 *      (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>,
 *                                                      All Rights Reserved.
 *
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License
 *      as published by the Free Software Foundation; either version
 *      2 of the License, or (at your option) any later version.
 *
 *      Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
 *      warranty for any of this software. This material is provided
 *      "AS-IS" and at no charge.
 *
 *      (c) Copyright 1995    Alan Cox <alan@lxorguk.ukuu.org.uk>
 *
 *      Software only watchdog driver. Unlike its big brother the WDT501P
 *      driver this won't always recover a failed machine.
 */


#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/init.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/reboot.h>
#include <linux/timer.h>
#include <linux/types.h>
#include <linux/watchdog.h>


#define TIMER_MARGIN	60		
/* Default is 60 seconds */

static unsigned int soft_margin = TIMER_MARGIN;	
/* in seconds */
module_param(soft_margin, uint, 0);
MODULE_PARM_DESC(soft_margin,
	"Watchdog soft_margin in seconds. (0 < soft_margin < 65536, default="
					__MODULE_STRING(TIMER_MARGIN) ")");


static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout,
		"Watchdog cannot be stopped once started (default="
				__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");


static int soft_noboot;
module_param(soft_noboot, int, 0);
MODULE_PARM_DESC(soft_noboot,
	"Softdog action, set to 1 to ignore reboots, 0 to reboot (default=0)");


static int soft_panic;
module_param(soft_panic, int, 0);
MODULE_PARM_DESC(soft_panic,
	"Softdog action, set to 1 to panic, 0 to reboot (default=0)");


static void softdog_fire(unsigned long data) { module_put(THIS_MODULE); if (soft_noboot) { pr_crit("Triggered - Reboot ignored\n"); } else if (soft_panic) { pr_crit("Initiating panic\n"); panic("Software Watchdog Timer expired"); } else { pr_crit("Initiating system reboot\n"); emergency_restart(); pr_crit("Reboot didn't ?????\n"); } }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git1423.73%325.00%
anithra p janakiramananithra p janakiraman1322.03%18.33%
joe perchesjoe perches1220.34%18.33%
dave jonesdave jones610.17%18.33%
li rongqingli rongqing58.47%18.33%
wim van sebroeckwim van sebroeck46.78%18.33%
wolfram sangwolfram sang35.08%216.67%
eric w. biedermaneric w. biederman11.69%18.33%
andrew mortonandrew morton11.69%18.33%
Total59100.00%12100.00%

static struct timer_list softdog_ticktock = TIMER_INITIALIZER(softdog_fire, 0, 0);
static int softdog_ping(struct watchdog_device *w) { if (!mod_timer(&softdog_ticktock, jiffies + (w->timeout * HZ))) __module_get(THIS_MODULE); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
wim van sebroeckwim van sebroeck1847.37%116.67%
li rongqingli rongqing821.05%116.67%
alan coxalan cox821.05%116.67%
pre-gitpre-git25.26%116.67%
wolfram sangwolfram sang12.63%116.67%
dave jonesdave jones12.63%116.67%
Total38100.00%6100.00%


static int softdog_stop(struct watchdog_device *w) { if (del_timer(&softdog_ticktock)) module_put(THIS_MODULE); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
wim van sebroeckwim van sebroeck1555.56%125.00%
li rongqingli rongqing725.93%125.00%
alan coxalan cox414.81%125.00%
wolfram sangwolfram sang13.70%125.00%
Total27100.00%4100.00%

static struct watchdog_info softdog_info = { .identity = "Software Watchdog", .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, }; static struct watchdog_ops softdog_ops = { .owner = THIS_MODULE, .start = softdog_ping, .stop = softdog_stop, }; static struct watchdog_device softdog_dev = { .info = &softdog_info, .ops = &softdog_ops, .min_timeout = 1, .max_timeout = 65535, .timeout = TIMER_MARGIN, };
static int __init softdog_init(void) { int ret; watchdog_init_timeout(&softdog_dev, soft_margin, NULL); watchdog_set_nowayout(&softdog_dev, nowayout); watchdog_stop_on_reboot(&softdog_dev); ret = watchdog_register_device(&softdog_dev); if (ret) return ret; pr_info("initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d (nowayout=%d)\n", soft_noboot, softdog_dev.timeout, soft_panic, nowayout); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git3144.93%433.33%
alan coxalan cox1318.84%18.33%
wolfram sangwolfram sang1115.94%216.67%
wim van sebroeckwim van sebroeck68.70%18.33%
joe perchesjoe perches22.90%18.33%
damien riegeldamien riegel22.90%18.33%
anithra p janakiramananithra p janakiraman22.90%18.33%
dave jonesdave jones22.90%18.33%
Total69100.00%12100.00%

module_init(softdog_init);
static void __exit softdog_exit(void) { watchdog_unregister_device(&softdog_dev); }

Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git1280.00%360.00%
alan coxalan cox213.33%120.00%
wolfram sangwolfram sang16.67%120.00%
Total15100.00%5100.00%

module_exit(softdog_exit); MODULE_AUTHOR("Alan Cox"); MODULE_DESCRIPTION("Software Watchdog Device Driver"); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
pre-gitpre-git10121.96%1131.43%
wim van sebroeckwim van sebroeck10121.96%411.43%
alan coxalan cox7516.30%25.71%
wolfram sangwolfram sang5311.52%617.14%
anithra p janakiramananithra p janakiraman357.61%12.86%
dave jonesdave jones275.87%25.71%
joe perchesjoe perches214.57%12.86%
li rongqingli rongqing204.35%12.86%
andrew mortonandrew morton112.39%25.71%
art haasart haas102.17%12.86%
tim schmielautim schmielau20.43%12.86%
damien riegeldamien riegel20.43%12.86%
andrey paninandrey panin10.22%12.86%
eric w. biedermaneric w. biederman10.22%12.86%
Total460100.00%35100.00%
Directory: drivers/watchdog
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.