git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
drivers
/
char
/
lp.c
diff --git
a/drivers/char/lp.c
b/drivers/char/lp.c
index
92a54cb
..
b51d08b
100644
(file)
--- a/
drivers/char/lp.c
+++ b/
drivers/char/lp.c
@@
-12,7
+12,7
@@
* "lp=" command line parameters added by Grant Guenther, grant@torque.net
* lp_read (Status readback) support added by Carsten Gross,
* carsten@sol.wohnheim.uni-ulm.de
* "lp=" command line parameters added by Grant Guenther, grant@torque.net
* lp_read (Status readback) support added by Carsten Gross,
* carsten@sol.wohnheim.uni-ulm.de
- * Support for parport by Philip Blundell <
Philip.Blundell@pobox.com
>
+ * Support for parport by Philip Blundell <
philb@gnu.org
>
* Parport sharing hacking by Andrea Arcangeli
* Fixed kernel_(to/from)_user memory copy to check for errors
* by Riccardo Facchetti <fizban@tin.it>
* Parport sharing hacking by Andrea Arcangeli
* Fixed kernel_(to/from)_user memory copy to check for errors
* by Riccardo Facchetti <fizban@tin.it>
@@
-114,19
+114,19
@@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/init.h>
-#include <linux/config.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/sched.h>
#include <linux/smp_lock.h>
-#include <linux/devfs_fs_kernel.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <linux/console.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <linux/console.h>
#include <linux/device.h>
+#include <linux/wait.h>
+#include <linux/jiffies.h>
#include <linux/parport.h>
#undef LP_STATS
#include <linux/parport.h>
#undef LP_STATS
@@
-145,7
+145,7
@@
static struct lp_struct lp_table[LP_NO];
static unsigned int lp_count = 0;
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
#ifdef CONFIG_LP_CONSOLE
static struct parport *console_registered; // initially NULL
@@
-218,6
+218,7
@@
static int lp_reset(int minor)
static void lp_error (int minor)
{
static void lp_error (int minor)
{
+ DEFINE_WAIT(wait);
int polling;
if (LP_F(minor) & LP_ABORT)
int polling;
if (LP_F(minor) & LP_ABORT)
@@
-225,8
+226,9
@@
static void lp_error (int minor)
polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE;
if (polling) lp_release_parport (&lp_table[minor]);
polling = lp_table[minor].dev->port->irq == PARPORT_IRQ_NONE;
if (polling) lp_release_parport (&lp_table[minor]);
- interruptible_sleep_on_timeout (&lp_table[minor].waitq,
- LP_TIMEOUT_POLLED);
+ prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE);
+ schedule_timeout(LP_TIMEOUT_POLLED);
+ finish_wait(&lp_table[minor].waitq, &wait);
if (polling) lp_claim_parport_or_block (&lp_table[minor]);
else parport_yield_blocking (lp_table[minor].dev);
}
if (polling) lp_claim_parport_or_block (&lp_table[minor]);
else parport_yield_blocking (lp_table[minor].dev);
}
@@
-294,7
+296,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)
{
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;
struct parport *port = lp_table[minor].dev->port;
char *kbuf = lp_table[minor].lp_buffer;
ssize_t retv = 0;
@@
-304,7
+306,7
@@
static ssize_t lp_write(struct file * file, const char __user * buf,
(LP_F(minor) & LP_ABORT));
#ifdef LP_STATS
(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;
lp_table[minor].runchars = 0;
lp_table[minor].lastcall = jiffies;
@@
-314,12
+316,14
@@
static ssize_t lp_write(struct file * file, const char __user * buf,
if (copy_size > LP_BUFFER_SIZE)
copy_size = LP_BUFFER_SIZE;
if (copy_size > LP_BUFFER_SIZE)
copy_size = LP_BUFFER_SIZE;
- if (copy_from_user (kbuf, buf, copy_size))
- return -EFAULT;
-
if (down_interruptible (&lp_table[minor].port_mutex))
return -EINTR;
if (down_interruptible (&lp_table[minor].port_mutex))
return -EINTR;
+ if (copy_from_user (kbuf, buf, copy_size)) {
+ retv = -EFAULT;
+ goto out_unlock;
+ }
+
/* Claim Parport or sleep until it becomes available
*/
lp_claim_parport_or_block (&lp_table[minor]);
/* Claim Parport or sleep until it becomes available
*/
lp_claim_parport_or_block (&lp_table[minor]);
@@
-398,7
+402,7
@@
static ssize_t lp_write(struct file * file, const char __user * buf,
lp_table[minor].current_mode = IEEE1284_MODE_COMPAT;
lp_release_parport (&lp_table[minor]);
}
lp_table[minor].current_mode = IEEE1284_MODE_COMPAT;
lp_release_parport (&lp_table[minor]);
}
-
+out_unlock:
up (&lp_table[minor].port_mutex);
return retv;
up (&lp_table[minor].port_mutex);
return retv;
@@
-410,7
+414,8
@@
static ssize_t lp_write(struct file * file, const char __user * buf,
static ssize_t lp_read(struct file * file, char __user * buf,
size_t count, loff_t *ppos)
{
static ssize_t lp_read(struct file * file, char __user * buf,
size_t count, loff_t *ppos)
{
- unsigned int minor=iminor(file->f_dentry->d_inode);
+ DEFINE_WAIT(wait);
+ 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;
struct parport *port = lp_table[minor].dev->port;
ssize_t retval = 0;
char *kbuf = lp_table[minor].lp_buffer;
@@
-458,9
+463,11
@@
static ssize_t lp_read(struct file * file, char __user * buf,
retval = -EIO;
goto out;
}
retval = -EIO;
goto out;
}
- } else
- interruptible_sleep_on_timeout (&lp_table[minor].waitq,
- LP_TIMEOUT_POLLED);
+ } else {
+ prepare_to_wait(&lp_table[minor].waitq, &wait, TASK_INTERRUPTIBLE);
+ schedule_timeout(LP_TIMEOUT_POLLED);
+ finish_wait(&lp_table[minor].waitq, &wait);
+ }
if (signal_pending (current)) {
retval = -ERESTARTSYS;
if (signal_pending (current)) {
retval = -ERESTARTSYS;
@@
-518,7
+525,7
@@
static int lp_open(struct inode * inode, struct file * file)
return -EIO;
}
}
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;
if (!lp_table[minor].lp_buffer) {
LP_F(minor) &= ~LP_BUSY;
return -ENOMEM;
@@
-659,7
+666,7
@@
static int lp_ioctl(struct inode *inode, struct file *file,
return retval;
}
return retval;
}
-static struct file_operations lp_fops = {
+static
const
struct file_operations lp_fops = {
.owner = THIS_MODULE,
.write = lp_write,
.ioctl = lp_ioctl,
.owner = THIS_MODULE,
.write = lp_write,
.ioctl = lp_ioctl,
@@
-796,10
+803,8
@@
static int lp_register(int nr, struct parport *port)
if (reset)
lp_reset(nr);
if (reset)
lp_reset(nr);
- class_
simple_device_add(lp_class
, MKDEV(LP_MAJOR, nr), NULL,
+ class_
device_create(lp_class, NULL
, MKDEV(LP_MAJOR, nr), NULL,
"lp%d", nr);
"lp%d", nr);
- devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
- "printers/%d", nr);
printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
(port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name,
(port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
@@
-898,11
+903,10
@@
static int __init lp_init (void)
return -EIO;
}
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);
if (IS_ERR(lp_class)) {
err = PTR_ERR(lp_class);
- goto out_
devfs
;
+ goto out_
reg
;
}
if (parport_register_driver (&lp_driver)) {
}
if (parport_register_driver (&lp_driver)) {
@@
-922,9
+926,8
@@
static int __init lp_init (void)
return 0;
out_class:
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;
}
unregister_chrdev(LP_MAJOR, "lp");
return err;
}
@@
-972,11
+975,9
@@
static void lp_cleanup_module (void)
if (lp_table[offset].dev == NULL)
continue;
parport_unregister_device(lp_table[offset].dev);
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));
+ class_device_destroy(lp_class, MKDEV(LP_MAJOR, offset));
}
}
- devfs_remove("printers");
- class_simple_destroy(lp_class);
+ class_destroy(lp_class);
}
__setup("lp=", lp_setup);
}
__setup("lp=", lp_setup);