X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fchar%2Flp.c;h=81674d7c56c7e74c655e62bb86f2d20cc350aae3;hb=d6898556e90ba9842e59ac9c2425b42ea33019b4;hp=4dee945031d45cf46d61b604bcbfffe58f1ac895;hpb=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 4dee945..81674d7 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -114,13 +114,10 @@ #include #include -#include #include #include #include #include -#include -#include #include #include #include @@ -128,6 +125,7 @@ #include #include #include +#include #include #undef LP_STATS @@ -140,16 +138,13 @@ /* if you have more than 8 printers, remember to increase LP_NO */ #define LP_NO 8 -/* ROUND_UP macro from fs/select.c */ -#define ROUND_UP(x,y) (((x)+(y)-1)/(y)) - static struct lp_struct lp_table[LP_NO]; static unsigned int lp_count = 0; -static struct class_simple *lp_class; +static struct class *lp_class; #ifdef CONFIG_LP_CONSOLE -static struct parport *console_registered; // initially NULL +static struct parport *console_registered; #endif /* CONFIG_LP_CONSOLE */ #undef LP_DEBUG @@ -297,7 +292,7 @@ static int lp_wait_ready(int minor, int nonblock) static ssize_t lp_write(struct file * file, const char __user * buf, size_t count, loff_t *ppos) { - unsigned int minor = iminor(file->f_dentry->d_inode); + unsigned int minor = iminor(file->f_path.dentry->d_inode); struct parport *port = lp_table[minor].dev->port; char *kbuf = lp_table[minor].lp_buffer; ssize_t retv = 0; @@ -307,7 +302,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf, (LP_F(minor) & LP_ABORT)); #ifdef LP_STATS - if (jiffies-lp_table[minor].lastcall > LP_TIME(minor)) + if (time_after(jiffies, lp_table[minor].lastcall + LP_TIME(minor))) lp_table[minor].runchars = 0; lp_table[minor].lastcall = jiffies; @@ -416,7 +411,7 @@ static ssize_t lp_read(struct file * file, char __user * buf, size_t count, loff_t *ppos) { DEFINE_WAIT(wait); - unsigned int minor=iminor(file->f_dentry->d_inode); + unsigned int minor=iminor(file->f_path.dentry->d_inode); struct parport *port = lp_table[minor].dev->port; ssize_t retval = 0; char *kbuf = lp_table[minor].lp_buffer; @@ -526,7 +521,7 @@ static int lp_open(struct inode * inode, struct file * file) return -EIO; } } - lp_table[minor].lp_buffer = (char *) kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); + lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); if (!lp_table[minor].lp_buffer) { LP_F(minor) &= ~LP_BUSY; return -ENOMEM; @@ -653,7 +648,7 @@ static int lp_ioctl(struct inode *inode, struct file *file, (par_timeout.tv_usec < 0)) { return -EINVAL; } - to_jiffies = ROUND_UP(par_timeout.tv_usec, 1000000/HZ); + to_jiffies = DIV_ROUND_UP(par_timeout.tv_usec, 1000000/HZ); to_jiffies += par_timeout.tv_sec * (long) HZ; if (to_jiffies <= 0) { return -EINVAL; @@ -667,7 +662,7 @@ static int lp_ioctl(struct inode *inode, struct file *file, return retval; } -static struct file_operations lp_fops = { +static const struct file_operations lp_fops = { .owner = THIS_MODULE, .write = lp_write, .ioctl = lp_ioctl, @@ -754,8 +749,8 @@ static struct console lpcons = { /* --- initialisation code ------------------------------------- */ static int parport_nr[LP_NO] = { [0 ... LP_NO-1] = LP_PARPORT_UNSPEC }; -static char *parport[LP_NO] = { NULL, }; -static int reset = 0; +static char *parport[LP_NO]; +static int reset; module_param_array(parport, charp, NULL, 0); module_param(reset, bool, 0); @@ -763,10 +758,10 @@ module_param(reset, bool, 0); #ifndef MODULE static int __init lp_setup (char *str) { - static int parport_ptr; // initially zero + static int parport_ptr; int x; - if (get_option (&str, &x)) { + if (get_option(&str, &x)) { if (x == 0) { /* disable driver on "lp=" or "lp=0" */ parport_nr[0] = LP_PARPORT_OFF; @@ -804,10 +799,7 @@ static int lp_register(int nr, struct parport *port) if (reset) lp_reset(nr); - class_simple_device_add(lp_class, MKDEV(LP_MAJOR, nr), NULL, - "lp%d", nr); - devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO, - "printers/%d", nr); + device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr); printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven"); @@ -815,7 +807,7 @@ static int lp_register(int nr, struct parport *port) #ifdef CONFIG_LP_CONSOLE if (!nr) { if (port->modes & PARPORT_MODE_SAFEININT) { - register_console (&lpcons); + register_console(&lpcons); console_registered = port; printk (KERN_INFO "lp%d: console ready\n", CONSOLE_LP); } else @@ -831,8 +823,7 @@ static void lp_attach (struct parport *port) { unsigned int i; - switch (parport_nr[0]) - { + switch (parport_nr[0]) { case LP_PARPORT_UNSPEC: case LP_PARPORT_AUTO: if (parport_nr[0] == LP_PARPORT_AUTO && @@ -863,7 +854,7 @@ static void lp_detach (struct parport *port) /* Write this some day. */ #ifdef CONFIG_LP_CONSOLE if (console_registered == port) { - unregister_console (&lpcons); + unregister_console(&lpcons); console_registered = NULL; } #endif /* CONFIG_LP_CONSOLE */ @@ -906,11 +897,10 @@ static int __init lp_init (void) return -EIO; } - devfs_mk_dir("printers"); - lp_class = class_simple_create(THIS_MODULE, "printer"); + lp_class = class_create(THIS_MODULE, "printer"); if (IS_ERR(lp_class)) { err = PTR_ERR(lp_class); - goto out_devfs; + goto out_reg; } if (parport_register_driver (&lp_driver)) { @@ -930,9 +920,8 @@ static int __init lp_init (void) return 0; out_class: - class_simple_destroy(lp_class); -out_devfs: - devfs_remove("printers"); + class_destroy(lp_class); +out_reg: unregister_chrdev(LP_MAJOR, "lp"); return err; } @@ -980,11 +969,9 @@ static void lp_cleanup_module (void) if (lp_table[offset].dev == NULL) continue; parport_unregister_device(lp_table[offset].dev); - devfs_remove("printers/%d", offset); - class_simple_device_remove(MKDEV(LP_MAJOR, offset)); + device_destroy(lp_class, MKDEV(LP_MAJOR, offset)); } - devfs_remove("printers"); - class_simple_destroy(lp_class); + class_destroy(lp_class); } __setup("lp=", lp_setup);