Skip to contentSkip to conversation

mb800 watchdog driver

DISCUSSION Grzegorz Jaskiewicz 4 participants 4 messages Mar 13, 2003

lore
Share & tools
lore
#1 lore raw
Quoted 7 lines · Grzegorz Jaskiewicz

I've wrote small driver for mb800 motherboards (x86, intel). And i want to share with others.
Any comments/patches are welcome.

#include <sys/syscall.h>

not needed.

Quoted 1 line

#include <linux/version.h>

not needed.

Quoted 2 lines

#include <linux/errno.h>
#include <linux/stddef.h>

not needed.

Quoted 2 lines

#include <asm/page.h>
#include <asm/pgtable.h>

not needed.

Quoted 5 lines

#ifdef CONFIG_DEVFS_FS
#include <linux/devfs_fs_kernel.h>
#else
#error "this driver requires devfs, otherwise it would not work - sorry dude" #endif

devfs only drivers == EVIL. Pure EVIL.

Quoted 1 line

spinlock_t tab_lock;

can be static

Quoted 2 lines

static struct proc_dir_entry *proc_mtd;
int tab_o_count;

unused

Quoted 6 lines

static struct file_operations tabfs = {

   owner   : THIS_MODULE,
   open    : open_wdog,      /* open */
   write   : write_wdog,	/* write */

release : close_wdog, /* release */
};

use C99 .owner = THIS_MODULE
Ok, this is a 2.4 driver, but it makes forward porting simpler. Also, the comments are pointless.

Quoted 2 lines

void LockChip()
void UnLockChip()

can be static (as can most other functions in this file)

Quoted 8 lines

/*

   if (check_region(0x2e, 2)){
	printk(KERN_INFO "tab: my I/O space is allready in use, can't share it .. sorry\n");
	return -1;

}

   request_region(0x2e, 2, "mb800 watchdog");

*/

1. Probably shouldn't be commented out.
2. Don't use check_region, just check return of request_region.

Quoted 1 line
   printk(KERN_INFO "watchdog: DIE !!!\n");

Something more userfriendly "mb8wdog: unloading\n" would be nicer.

Quoted 1 line
	printk(KERN_INFO "MB800 WATCHDOG: LOAD DEVICE ENDED\n");

KERN_DEBUG ? and STOP SHOUTING!

Quoted 1 line
	printk(KERN_INFO "MB800 WATCHDOG: ENTER CREATE DISPATCH\n");

in fact, these printk's should probably be something like dprintk's with dprintk being defined at the top of source like..

#define DEBUG
#ifndef DEBUG

# define dprintk(format, args...)
#else
# define dprintk(format, args...) printk(KERN_DEBUG "mb8wdog:", ## args)
#endif
Quoted 10 lines
   if (copy_from_user(&b, buf, 1)){
	return -EFAULT;
   }

   if (b){    
	EnableAndSetWatchdog(b);
   }
   else{
	DisableWatchdog();
   }

Please choose one indentation style, and stick to it. Preferably the one described in Documenation/CodingStyle

	if (b) {
		EnableAndSetWatchdog(b);
	} else {
		DisableWatchdog();
	}

Other than these small nits, I don't see any problems with it. The biggest issue is the devfs-only requirement, which as I mentioned, is really evil, and afaics, totally unnecessary.

Dave

#2 lore raw
Quoted 9 lines · Dave Jones

in fact, these printk's should probably be something like dprintk's with dprintk being defined at the top of source like..

#define DEBUG
#ifndef DEBUG

# define dprintk(format, args...)
#else
# define dprintk(format, args...) printk(KERN_DEBUG "mb8wdog:", ## args)
                                                               ^^
Quoted 1 line

#endif

You might want to put an additional whitespace at the indicated position, that works around a gcc 2.x bug.

J�rn

Signature · 3 lines
Mundie uses a textbook tactic of manipulation: start with some
reasonable talk, and lead the audience to an unreasonable conclusion.
-- Bruce Perens
#3 lore raw
In reply to Dave Jones
Quoted 10 lines · Dave Jones
Quoted 7 lines · Grzegorz Jaskiewicz

I've wrote small driver for mb800 motherboards (x86, intel). And i want to share with others.
Any comments/patches are welcome.

#include <sys/syscall.h>

not needed.

Nor does it even compile with any recent kernel..