Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133769
b: refs/heads/master
c: 9b655e0
h: refs/heads/master
i:
  133767: 2880fa0
v: v3
  • Loading branch information
Phil Sutter authored and Wim Van Sebroeck committed Mar 25, 2009
1 parent b4264b1 commit 1f9b5f5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 371d3525e3b9d57c00ca307f8ee4ca51a2eaa70b
refs/heads/master: 9b655e07d77e3b1a00c1c8302e2ef3b7fb719de3
75 changes: 37 additions & 38 deletions trunk/drivers/watchdog/rc32434_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
*
*/

#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/reboot.h>
#include <linux/smp_lock.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/uaccess.h>

#include <asm/bootinfo.h>
#include <asm/time.h>
#include <asm/mach-rc32434/integ.h>
#include <linux/module.h> /* For module specific items */
#include <linux/moduleparam.h> /* For new moduleparam's */
#include <linux/types.h> /* For standard types (like size_t) */
#include <linux/errno.h> /* For the -ENODEV/... values */
#include <linux/kernel.h> /* For printk/panic/... */
#include <linux/fs.h> /* For file operations */
#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV
(WATCHDOG_MINOR) */
#include <linux/watchdog.h> /* For the watchdog specific items */
#include <linux/init.h> /* For __init/__exit/... */
#include <linux/platform_device.h> /* For platform_driver framework */
#include <linux/uaccess.h> /* For copy_to_user/put_user/... */

#include <asm/mach-rc32434/integ.h> /* For the Watchdog registers */

#define PFX KBUILD_MODNAME ": "

#define VERSION "0.4"

Expand Down Expand Up @@ -90,21 +90,24 @@ static void rc32434_wdt_start(void)
or = 1 << RC32434_WTC_EN;

SET_BITS(wdt_reg->wtc, or, nand);

printk(KERN_INFO PFX "Started watchdog timer.\n");
}

static void rc32434_wdt_stop(void)
{
/* Disable WDT */
SET_BITS(wdt_reg->wtc, 0, 1 << RC32434_WTC_EN);

printk(KERN_INFO PFX "Stopped watchdog timer.\n");
}

static int rc32434_wdt_set(int new_timeout)
{
int max_to = WTCOMP2SEC((u32)-1);

if (new_timeout < 0 || new_timeout > max_to) {
printk(KERN_ERR KBUILD_MODNAME
": timeout value must be between 0 and %d",
printk(KERN_ERR PFX "timeout value must be between 0 and %d",
max_to);
return -EINVAL;
}
Expand Down Expand Up @@ -137,11 +140,10 @@ static int rc32434_wdt_release(struct inode *inode, struct file *file)
{
if (expect_close == 42) {
rc32434_wdt_stop();
printk(KERN_INFO KBUILD_MODNAME ": disabling watchdog timer\n");
module_put(THIS_MODULE);
} else {
printk(KERN_CRIT KBUILD_MODNAME
": device closed unexpectedly. WDT will not stop !\n");
printk(KERN_CRIT PFX
"device closed unexpectedly. WDT will not stop!\n");
rc32434_wdt_ping();
}
clear_bit(0, &rc32434_wdt_device.inuse);
Expand Down Expand Up @@ -185,19 +187,16 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
.identity = "RC32434_WDT Watchdog",
};
switch (cmd) {
case WDIOC_KEEPALIVE:
rc32434_wdt_ping();
case WDIOC_GETSUPPORT:
if (copy_to_user(argp, &ident, sizeof(ident)))
return -EFAULT;
break;
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
value = 0;
if (copy_to_user(argp, &value, sizeof(int)))
return -EFAULT;
break;
case WDIOC_GETSUPPORT:
if (copy_to_user(argp, &ident, sizeof(ident)))
return -EFAULT;
break;
case WDIOC_SETOPTIONS:
if (copy_from_user(&value, argp, sizeof(int)))
return -EFAULT;
Expand All @@ -212,6 +211,9 @@ static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
return -EINVAL;
}
break;
case WDIOC_KEEPALIVE:
rc32434_wdt_ping();
break;
case WDIOC_SETTIMEOUT:
if (copy_from_user(&new_timeout, argp, sizeof(int)))
return -EFAULT;
Expand Down Expand Up @@ -242,8 +244,8 @@ static struct miscdevice rc32434_wdt_miscdev = {
.fops = &rc32434_wdt_fops,
};

static char banner[] __devinitdata = KERN_INFO KBUILD_MODNAME
": Watchdog Timer version " VERSION ", timer margin: %d sec\n";
static char banner[] __devinitdata = KERN_INFO PFX
"Watchdog Timer version " VERSION ", timer margin: %d sec\n";

static int __devinit rc32434_wdt_probe(struct platform_device *pdev)
{
Expand All @@ -252,22 +254,19 @@ static int __devinit rc32434_wdt_probe(struct platform_device *pdev)

r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb532_wdt_res");
if (!r) {
printk(KERN_ERR KBUILD_MODNAME
"failed to retrieve resources\n");
printk(KERN_ERR PFX "failed to retrieve resources\n");
return -ENODEV;
}

wdt_reg = ioremap_nocache(r->start, r->end - r->start);
if (!wdt_reg) {
printk(KERN_ERR KBUILD_MODNAME
"failed to remap I/O resources\n");
printk(KERN_ERR PFX "failed to remap I/O resources\n");
return -ENXIO;
}

ret = misc_register(&rc32434_wdt_miscdev);
if (ret < 0) {
printk(KERN_ERR KBUILD_MODNAME
"failed to register watchdog device\n");
printk(KERN_ERR PFX "failed to register watchdog device\n");
goto unmap;
}

Expand All @@ -287,7 +286,7 @@ static int __devexit rc32434_wdt_remove(struct platform_device *pdev)
return 0;
}

static struct platform_driver rc32434_wdt = {
static struct platform_driver rc32434_wdt_driver = {
.probe = rc32434_wdt_probe,
.remove = __devexit_p(rc32434_wdt_remove),
.driver = {
Expand All @@ -297,12 +296,12 @@ static struct platform_driver rc32434_wdt = {

static int __init rc32434_wdt_init(void)
{
return platform_driver_register(&rc32434_wdt);
return platform_driver_register(&rc32434_wdt_driver);
}

static void __exit rc32434_wdt_exit(void)
{
platform_driver_unregister(&rc32434_wdt);
platform_driver_unregister(&rc32434_wdt_driver);
}

module_init(rc32434_wdt_init);
Expand Down

0 comments on commit 1f9b5f5

Please sign in to comment.