summaryrefslogtreecommitdiffstats
path: root/target/linux/ar7/files/drivers/char
diff options
context:
space:
mode:
authormatteo <matteo@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-09-11 21:19:57 +0000
committermatteo <matteo@3c298f89-4303-0410-b956-a3cf2f4a3e73>2007-09-11 21:19:57 +0000
commit6485c8ba0a21f44100aa96123f2edd70fe9edbe6 (patch)
treeb97ce2d7c30acc1ff98fc64889cd3c40ea97218d /target/linux/ar7/files/drivers/char
parent02c9cd23690727767b933f700a10296d18b47a84 (diff)
AR7: Cleanups (closes: #2323)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8756 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ar7/files/drivers/char')
-rw-r--r--target/linux/ar7/files/drivers/char/ar7_gpio.c11
-rw-r--r--target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c63
2 files changed, 38 insertions, 36 deletions
diff --git a/target/linux/ar7/files/drivers/char/ar7_gpio.c b/target/linux/ar7/files/drivers/char/ar7_gpio.c
index a5245da35..c0ee897e2 100644
--- a/target/linux/ar7/files/drivers/char/ar7_gpio.c
+++ b/target/linux/ar7/files/drivers/char/ar7_gpio.c
@@ -25,9 +25,8 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <asm/uaccess.h>
-#include <asm/io.h>
-
+#include <linux/uaccess.h>
+#include <linux/io.h>
#include <linux/types.h>
#include <linux/cdev.h>
#include <gpio.h>
@@ -39,7 +38,7 @@ MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>");
MODULE_DESCRIPTION(LONGNAME);
MODULE_LICENSE("GPL");
-static int ar7_gpio_major = 0;
+static int ar7_gpio_major;
static ssize_t ar7_gpio_write(struct file *file, const char __user *buf,
size_t len, loff_t *ppos)
@@ -84,8 +83,8 @@ static ssize_t ar7_gpio_write(struct file *file, const char __user *buf,
return len;
}
-static ssize_t ar7_gpio_read(struct file *file, char __user * buf,
- size_t len, loff_t * ppos)
+static ssize_t ar7_gpio_read(struct file *file, char __user *buf,
+ size_t len, loff_t *ppos)
{
int pin = iminor(file->f_dentry->d_inode);
int value;
diff --git a/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c b/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c
index 271025008..04c2e2e94 100644
--- a/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c
+++ b/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c
@@ -33,11 +33,10 @@
#include <linux/reboot.h>
#include <linux/fs.h>
#include <linux/ioport.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
#include <asm/addrspace.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
#include <asm/ar7/ar7.h>
#define DRVNAME "ar7_wdt"
@@ -56,7 +55,7 @@ static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close");
-typedef struct {
+struct ar7_wdt {
u32 kick_lock;
u32 kick;
u32 change_lock;
@@ -65,7 +64,7 @@ typedef struct {
u32 disable;
u32 prescale_lock;
u32 prescale;
-} ar7_wdt_t;
+};
static struct semaphore open_semaphore;
static unsigned expect_close;
@@ -73,15 +72,14 @@ static unsigned expect_close;
/* XXX currently fixed, allows max margin ~68.72 secs */
#define prescale_value 0xffff
-// Offset of the WDT registers
+/* Offset of the WDT registers */
static unsigned long ar7_regs_wdt;
-// Pointer to the remapped WDT IO space
-static ar7_wdt_t *ar7_wdt;
+/* Pointer to the remapped WDT IO space */
+static struct ar7_wdt *ar7_wdt;
static void ar7_wdt_get_regs(void)
{
u16 chip_id = ar7_chip_id();
- switch (chip_id)
- {
+ switch (chip_id) {
case AR7_CHIP_7100:
case AR7_CHIP_7200:
ar7_regs_wdt = AR7_REGS_WDT;
@@ -92,6 +90,7 @@ static void ar7_wdt_get_regs(void)
}
}
+
static void ar7_wdt_kick(u32 value)
{
ar7_wdt->kick_lock = 0x5555;
@@ -188,7 +187,9 @@ static int ar7_wdt_open(struct inode *inode, struct file *file)
static int ar7_wdt_release(struct inode *inode, struct file *file)
{
if (!expect_close) {
- printk(KERN_WARNING DRVNAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n");
+ printk(KERN_WARNING DRVNAME
+ ": watchdog device closed unexpectedly,"
+ "will not disable the watchdog timer\n");
} else if (!nowayout) {
ar7_wdt_disable_wdt();
}
@@ -197,8 +198,8 @@ static int ar7_wdt_release(struct inode *inode, struct file *file)
return 0;
}
-static int ar7_wdt_notify_sys(struct notifier_block *this,
- unsigned long code, void *unused)
+static int ar7_wdt_notify_sys(struct notifier_block *this,
+ unsigned long code, void *unused)
{
if (code == SYS_HALT || code == SYS_POWER_OFF)
if (!nowayout)
@@ -207,13 +208,12 @@ static int ar7_wdt_notify_sys(struct notifier_block *this,
return NOTIFY_DONE;
}
-static struct notifier_block ar7_wdt_notifier =
-{
+static struct notifier_block ar7_wdt_notifier = {
.notifier_call = ar7_wdt_notify_sys
};
-static ssize_t ar7_wdt_write(struct file *file, const char *data,
- size_t len, loff_t *ppos)
+static ssize_t ar7_wdt_write(struct file *file, const char *data,
+ size_t len, loff_t *ppos)
{
if (ppos != &file->f_pos)
return -ESPIPE;
@@ -237,19 +237,21 @@ static ssize_t ar7_wdt_write(struct file *file, const char *data,
return len;
}
-static int ar7_wdt_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static int ar7_wdt_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
{
static struct watchdog_info ident = {
.identity = LONGNAME,
- .firmware_version = 1,
+ .firmware_version = 1,
.options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING),
};
int new_margin;
-
+
switch (cmd) {
+ default:
+ return -ENOTTY;
case WDIOC_GETSUPPORT:
- if(copy_to_user((struct watchdog_info *)arg, &ident,
+ if (copy_to_user((struct watchdog_info *)arg, &ident,
sizeof(ident)))
return -EFAULT;
return 0;
@@ -274,8 +276,6 @@ static int ar7_wdt_ioctl(struct inode *inode, struct file *file,
if (put_user(margin, (int *)arg))
return -EFAULT;
return 0;
- default:
- return -ENOTTY;
}
}
@@ -297,14 +297,16 @@ static int __init ar7_wdt_init(void)
{
int rc;
- ar7_wdt_get_regs();
+ ar7_wdt_get_regs();
- if (!request_mem_region(ar7_regs_wdt, sizeof(ar7_wdt_t), LONGNAME)) {
+ if (!request_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt),
+ LONGNAME)) {
printk(KERN_WARNING DRVNAME ": watchdog I/O region busy\n");
return -EBUSY;
}
- ar7_wdt = (ar7_wdt_t *)ioremap(ar7_regs_wdt, sizeof(ar7_wdt_t));
+ ar7_wdt = (struct ar7_wdt *)
+ ioremap(ar7_regs_wdt, sizeof(struct ar7_wdt));
ar7_wdt_disable_wdt();
ar7_wdt_prescale(prescale_value);
@@ -320,7 +322,8 @@ static int __init ar7_wdt_init(void)
rc = register_reboot_notifier(&ar7_wdt_notifier);
if (rc) {
- printk(KERN_ERR DRVNAME ": unable to register reboot notifier\n");
+ printk(KERN_ERR DRVNAME
+ ": unable to register reboot notifier\n");
goto out_register;
}
goto out;
@@ -328,7 +331,7 @@ static int __init ar7_wdt_init(void)
out_register:
misc_deregister(&ar7_wdt_miscdev);
out_alloc:
- release_mem_region(ar7_regs_wdt, sizeof(ar7_wdt_t));
+ release_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt));
out:
return rc;
}
@@ -338,7 +341,7 @@ static void __exit ar7_wdt_cleanup(void)
unregister_reboot_notifier(&ar7_wdt_notifier);
misc_deregister(&ar7_wdt_miscdev);
iounmap(ar7_wdt);
- release_mem_region(ar7_regs_wdt, sizeof(ar7_wdt_t));
+ release_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt));
}
module_init(ar7_wdt_init);