Commit dbd0a54b authored by James Nelson's avatar James Nelson Committed by Linus Torvalds

[PATCH] tipar: Code cleanup

Correct the following issues:

- Remove reference to 2.5 kernel code.

- Switch some ints to unsigned ints.

- Correct KERN_ constants in printk's, and move most to pr_debug &
  pr_info Fix some >80 column lines and indenting.

Compile tested.
Signed-off-by: default avatarJames Nelson <james4765@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent efd52391
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
* the minor number. * the minor number.
* *
*/ */
#undef DEBUG /* change to #define to get debugging
* output - for pr_debug() */
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/version.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -74,9 +74,6 @@ ...@@ -74,9 +74,6 @@
#define DRIVER_LICENSE "GPL" #define DRIVER_LICENSE "GPL"
#define VERSION(ver,rel,seq) (((ver)<<16) | ((rel)<<8) | (seq)) #define VERSION(ver,rel,seq) (((ver)<<16) | ((rel)<<8) | (seq))
#if LINUX_VERSION_CODE < VERSION(2,5,0)
# define need_resched() (current->need_resched)
#endif
/* ----- global variables --------------------------------------------- */ /* ----- global variables --------------------------------------------- */
...@@ -143,7 +140,7 @@ White: ________ | ______ | _______ ...@@ -143,7 +140,7 @@ White: ________ | ______ | _______
static int static int
put_ti_parallel(int minor, unsigned char data) put_ti_parallel(int minor, unsigned char data)
{ {
int bit; unsigned int bit;
unsigned long max; unsigned long max;
for (bit = 0; bit < 8; bit++) { for (bit = 0; bit < 8; bit++) {
...@@ -187,7 +184,7 @@ put_ti_parallel(int minor, unsigned char data) ...@@ -187,7 +184,7 @@ put_ti_parallel(int minor, unsigned char data)
static int static int
get_ti_parallel(int minor) get_ti_parallel(int minor)
{ {
int bit; unsigned int bit;
unsigned char v, data = 0; unsigned char v, data = 0;
unsigned long max; unsigned long max;
...@@ -234,7 +231,8 @@ probe_ti_parallel(int minor) ...@@ -234,7 +231,8 @@ probe_ti_parallel(int minor)
outbyte(3, minor); outbyte(3, minor);
outbyte(i, minor); outbyte(i, minor);
udelay(delay); udelay(delay);
/*printk(KERN_DEBUG "Probing -> %i: 0x%02x 0x%02x\n", i, data & 0x30, seq[i]); */ pr_debug("tipar: Probing -> %i: 0x%02x 0x%02x\n", i,
data & 0x30, seq[i]);
if ((inbyte(minor) & 0x30) != seq[i]) { if ((inbyte(minor) & 0x30) != seq[i]) {
outbyte(3, minor); outbyte(3, minor);
return -1; return -1;
...@@ -279,7 +277,8 @@ tipar_close(struct inode *inode, struct file *file) ...@@ -279,7 +277,8 @@ tipar_close(struct inode *inode, struct file *file)
} }
static ssize_t static ssize_t
tipar_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos) tipar_write (struct file *file, const char __user *buf, size_t count,
loff_t * ppos)
{ {
unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR; unsigned int minor = iminor(file->f_dentry->d_inode) - TIPAR_MINOR;
ssize_t n; ssize_t n;
...@@ -405,7 +404,8 @@ tipar_setup(char *str) ...@@ -405,7 +404,8 @@ tipar_setup(char *str)
if (ints[1] != 0) if (ints[1] != 0)
timeout = ints[1]; timeout = ints[1];
else else
printk("tipar: wrong timeout value (0), using default value instead."); printk(KERN_WARNING "tipar: bad timeout value (0), "
"using default value instead");
if (ints[0] > 1) { if (ints[0] > 1) {
delay = ints[2]; delay = ints[2];
} }
...@@ -436,8 +436,8 @@ tipar_register(int nr, struct parport *port) ...@@ -436,8 +436,8 @@ tipar_register(int nr, struct parport *port)
goto out; goto out;
} }
class_simple_device_add(tipar_class, MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr), class_simple_device_add(tipar_class, MKDEV(TIPAR_MAJOR,
NULL, "par%d", nr); TIPAR_MINOR + nr), NULL, "par%d", nr);
/* Use devfs, tree: /dev/ticables/par/[0..2] */ /* Use devfs, tree: /dev/ticables/par/[0..2] */
err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr), err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
...@@ -446,14 +446,13 @@ tipar_register(int nr, struct parport *port) ...@@ -446,14 +446,13 @@ tipar_register(int nr, struct parport *port)
goto out_class; goto out_class;
/* Display informations */ /* Display informations */
printk(KERN_INFO "tipar%d: using %s (%s).\n", nr, port->name, pr_info("tipar%d: using %s (%s)\n", nr, port->name, (port->irq ==
(port->irq ==
PARPORT_IRQ_NONE) ? "polling" : "interrupt-driven"); PARPORT_IRQ_NONE) ? "polling" : "interrupt-driven");
if (probe_ti_parallel(nr) != -1) if (probe_ti_parallel(nr) != -1)
printk("tipar%d: link cable found !\n", nr); pr_info("tipar%d: link cable found\n", nr);
else else
printk("tipar%d: link cable not found.\n", nr); pr_info("tipar%d: link cable not found\n", nr);
err = 0; err = 0;
goto out; goto out;
...@@ -469,7 +468,7 @@ static void ...@@ -469,7 +468,7 @@ static void
tipar_attach(struct parport *port) tipar_attach(struct parport *port)
{ {
if (tp_count == PP_NO) { if (tp_count == PP_NO) {
printk("tipar: ignoring parallel port (max. %d)\n", PP_NO); pr_info("tipar: ignoring parallel port (max. %d)\n", PP_NO);
return; return;
} }
...@@ -494,11 +493,11 @@ tipar_init_module(void) ...@@ -494,11 +493,11 @@ tipar_init_module(void)
{ {
int err = 0; int err = 0;
printk("tipar: parallel link cable driver, version %s\n", pr_info("tipar: parallel link cable driver, version %s\n",
DRIVER_VERSION); DRIVER_VERSION);
if (register_chrdev(TIPAR_MAJOR, "tipar", &tipar_fops)) { if (register_chrdev(TIPAR_MAJOR, "tipar", &tipar_fops)) {
printk("tipar: unable to get major %d\n", TIPAR_MAJOR); printk(KERN_ERR "tipar: unable to get major %d\n", TIPAR_MAJOR);
err = -EIO; err = -EIO;
goto out; goto out;
} }
...@@ -512,7 +511,7 @@ tipar_init_module(void) ...@@ -512,7 +511,7 @@ tipar_init_module(void)
goto out_chrdev; goto out_chrdev;
} }
if (parport_register_driver(&tipar_driver)) { if (parport_register_driver(&tipar_driver)) {
printk("tipar: unable to register with parport\n"); printk(KERN_ERR "tipar: unable to register with parport\n");
err = -EIO; err = -EIO;
goto out; goto out;
} }
...@@ -546,7 +545,7 @@ tipar_cleanup_module(void) ...@@ -546,7 +545,7 @@ tipar_cleanup_module(void)
class_simple_destroy(tipar_class); class_simple_destroy(tipar_class);
devfs_remove("ticables/par"); devfs_remove("ticables/par");
printk("tipar: module unloaded !\n"); pr_info("tipar: module unloaded\n");
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment