X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fs390%2Fchar%2Ffs3270.c;h=40759c33477d1d38bca2400f034affbf24e3efcc;hb=1175b257c8a2cb384823621cad0c1e0945f74300;hp=735a7fcdeff51dd1616a0481a0ebaa68b57217bc;hpb=ed3cb6f039bb296457bfd2877cba6ad0287d8d54;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c index 735a7fc..40759c3 100644 --- a/drivers/s390/char/fs3270.c +++ b/drivers/s390/char/fs3270.c @@ -8,28 +8,27 @@ * -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation */ -#include #include #include #include #include #include #include +#include #include #include -#include #include #include #include "raw3270.h" #include "ctrlchar.h" -struct raw3270_fn fs3270_fn; +static struct raw3270_fn fs3270_fn; struct fs3270 { struct raw3270_view view; - pid_t fs_pid; /* Pid of controlling program. */ + struct pid *fs_pid; /* Pid of controlling program. */ int read_command; /* ccw command to use for reads. */ int write_command; /* ccw command to use for writes. */ int attention; /* Got attention. */ @@ -104,7 +103,7 @@ fs3270_restore_callback(struct raw3270_request *rq, void *data) fp = (struct fs3270 *) rq->view; if (rq->rc != 0 || rq->rescnt != 0) { if (fp->fs_pid) - kill_proc(fp->fs_pid, SIGHUP, 1); + kill_pid(fp->fs_pid, SIGHUP, 1); } fp->rdbuf_size = 0; raw3270_request_reset(rq); @@ -175,7 +174,7 @@ fs3270_save_callback(struct raw3270_request *rq, void *data) */ if (rq->rc != 0 || rq->rescnt == 0) { if (fp->fs_pid) - kill_proc(fp->fs_pid, SIGHUP, 1); + kill_pid(fp->fs_pid, SIGHUP, 1); fp->rdbuf_size = 0; } else fp->rdbuf_size = fp->rdbuf->size - rq->rescnt; @@ -218,17 +217,17 @@ static int fs3270_irq(struct fs3270 *fp, struct raw3270_request *rq, struct irb *irb) { /* Handle ATTN. Set indication and wake waiters for attention. */ - if (irb->scsw.dstat & DEV_STAT_ATTENTION) { + if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { fp->attention = 1; wake_up(&fp->wait); } if (rq) { - if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK) + if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) rq->rc = -EIO; else /* Normal end. Copy residual count. */ - rq->rescnt = irb->scsw.count; + rq->rescnt = irb->scsw.cmd.count; } return RAW3270_IO_DONE; } @@ -237,7 +236,7 @@ fs3270_irq(struct fs3270 *fp, struct raw3270_request *rq, struct irb *irb) * Process reads from fullscreen 3270. */ static ssize_t -fs3270_read(struct file *filp, char *data, size_t count, loff_t *off) +fs3270_read(struct file *filp, char __user *data, size_t count, loff_t *off) { struct fs3270 *fp; struct raw3270_request *rq; @@ -282,7 +281,7 @@ fs3270_read(struct file *filp, char *data, size_t count, loff_t *off) * Process writes to fullscreen 3270. */ static ssize_t -fs3270_write(struct file *filp, const char *data, size_t count, loff_t *off) +fs3270_write(struct file *filp, const char __user *data, size_t count, loff_t *off) { struct fs3270 *fp; struct raw3270_request *rq; @@ -319,9 +318,8 @@ fs3270_write(struct file *filp, const char *data, size_t count, loff_t *off) /* * process ioctl commands for the tube driver */ -static int -fs3270_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +static long +fs3270_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct fs3270 *fp; struct raw3270_iocb iocb; @@ -331,6 +329,7 @@ fs3270_ioctl(struct inode *inode, struct file *filp, if (!fp) return -ENODEV; rc = 0; + lock_kernel(); switch (cmd) { case TUBICMD: fp->read_command = arg; @@ -339,10 +338,10 @@ fs3270_ioctl(struct inode *inode, struct file *filp, fp->write_command = arg; break; case TUBGETI: - rc = put_user(fp->read_command, (char *) arg); + rc = put_user(fp->read_command, (char __user *) arg); break; case TUBGETO: - rc = put_user(fp->write_command,(char *) arg); + rc = put_user(fp->write_command,(char __user *) arg); break; case TUBGETMOD: iocb.model = fp->view.model; @@ -351,11 +350,12 @@ fs3270_ioctl(struct inode *inode, struct file *filp, iocb.pf_cnt = 24; iocb.re_cnt = 20; iocb.map = 0; - if (copy_to_user((char *) arg, &iocb, + if (copy_to_user((char __user *) arg, &iocb, sizeof(struct raw3270_iocb))) rc = -EFAULT; break; } + unlock_kernel(); return rc; } @@ -367,10 +367,9 @@ fs3270_alloc_view(void) { struct fs3270 *fp; - fp = (struct fs3270 *) kmalloc(sizeof(struct fs3270),GFP_KERNEL); + fp = kzalloc(sizeof(struct fs3270),GFP_KERNEL); if (!fp) return ERR_PTR(-ENOMEM); - memset(fp, 0, sizeof(struct fs3270)); fp->init = raw3270_request_alloc(0); if (IS_ERR(fp->init)) { kfree(fp); @@ -403,7 +402,7 @@ fs3270_release(struct raw3270_view *view) } /* View to a 3270 device. Can be console, tty or fullscreen. */ -struct raw3270_fn fs3270_fn = { +static struct raw3270_fn fs3270_fn = { .activate = fs3270_activate, .deactivate = fs3270_deactivate, .intv = (void *) fs3270_irq, @@ -419,36 +418,42 @@ fs3270_open(struct inode *inode, struct file *filp) { struct fs3270 *fp; struct idal_buffer *ib; - int minor, rc; + int minor, rc = 0; - if (imajor(filp->f_dentry->d_inode) != IBM_FS3270_MAJOR) + if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR) return -ENODEV; - minor = iminor(filp->f_dentry->d_inode); + minor = iminor(filp->f_path.dentry->d_inode); /* Check for minor 0 multiplexer. */ if (minor == 0) { - if (!current->signal->tty) - return -ENODEV; - if (current->signal->tty->driver->major != IBM_TTY3270_MAJOR) + struct tty_struct *tty = get_current_tty(); + if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) { + tty_kref_put(tty); return -ENODEV; - minor = current->signal->tty->index + RAW3270_FIRSTMINOR; + } + minor = tty->index + RAW3270_FIRSTMINOR; + tty_kref_put(tty); } + lock_kernel(); /* Check if some other program is already using fullscreen mode. */ fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor); if (!IS_ERR(fp)) { raw3270_put_view(&fp->view); - return -EBUSY; + rc = -EBUSY; + goto out; } /* Allocate fullscreen view structure. */ fp = fs3270_alloc_view(); - if (IS_ERR(fp)) - return PTR_ERR(fp); + if (IS_ERR(fp)) { + rc = PTR_ERR(fp); + goto out; + } init_waitqueue_head(&fp->wait); - fp->fs_pid = current->pid; + fp->fs_pid = get_pid(task_pid(current)); rc = raw3270_add_view(&fp->view, &fs3270_fn, minor); if (rc) { fs3270_free_view(&fp->view); - return rc; + goto out; } /* Allocate idal-buffer. */ @@ -456,7 +461,8 @@ fs3270_open(struct inode *inode, struct file *filp) if (IS_ERR(ib)) { raw3270_put_view(&fp->view); raw3270_del_view(&fp->view); - return PTR_ERR(fp); + rc = PTR_ERR(fp); + goto out; } fp->rdbuf = ib; @@ -464,10 +470,12 @@ fs3270_open(struct inode *inode, struct file *filp) if (rc) { raw3270_put_view(&fp->view); raw3270_del_view(&fp->view); - return rc; + goto out; } filp->private_data = fp; - return 0; +out: + unlock_kernel(); + return rc; } /* @@ -480,9 +488,10 @@ fs3270_close(struct inode *inode, struct file *filp) struct fs3270 *fp; fp = filp->private_data; - filp->private_data = 0; + filp->private_data = NULL; if (fp) { - fp->fs_pid = 0; + put_pid(fp->fs_pid); + fp->fs_pid = NULL; raw3270_reset(&fp->view); raw3270_put_view(&fp->view); raw3270_del_view(&fp->view); @@ -490,13 +499,14 @@ fs3270_close(struct inode *inode, struct file *filp) return 0; } -static struct file_operations fs3270_fops = { - .owner = THIS_MODULE, /* owner */ - .read = fs3270_read, /* read */ - .write = fs3270_write, /* write */ - .ioctl = fs3270_ioctl, /* ioctl */ - .open = fs3270_open, /* open */ - .release = fs3270_close, /* release */ +static const struct file_operations fs3270_fops = { + .owner = THIS_MODULE, /* owner */ + .read = fs3270_read, /* read */ + .write = fs3270_write, /* write */ + .unlocked_ioctl = fs3270_ioctl, /* ioctl */ + .compat_ioctl = fs3270_ioctl, /* ioctl */ + .open = fs3270_open, /* open */ + .release = fs3270_close, /* release */ }; /* @@ -508,11 +518,8 @@ fs3270_init(void) int rc; rc = register_chrdev(IBM_FS3270_MAJOR, "fs3270", &fs3270_fops); - if (rc) { - printk(KERN_ERR "fs3270 can't get major number %d: errno %d\n", - IBM_FS3270_MAJOR, rc); + if (rc) return rc; - } return 0; }