vmur.c (764a4a8e54cdd6efc5928f876aa9e35778f22377) vmur.c (23d805b647db6c2063a13089497615efa9deacdd)
1/*
2 * Linux driver for System z and s390 unit record devices
3 * (z/VM virtual punch, reader, printer)
4 *
5 * Copyright IBM Corp. 2001, 2007
6 * Authors: Malcolm Beattie <beattiem@uk.ibm.com>
7 * Michael Holzheu <holzheu@de.ibm.com>
8 * Frank Munzert <munzert@de.ibm.com>
9 */
10
11#include <linux/cdev.h>
1/*
2 * Linux driver for System z and s390 unit record devices
3 * (z/VM virtual punch, reader, printer)
4 *
5 * Copyright IBM Corp. 2001, 2007
6 * Authors: Malcolm Beattie <beattiem@uk.ibm.com>
7 * Michael Holzheu <holzheu@de.ibm.com>
8 * Frank Munzert <munzert@de.ibm.com>
9 */
10
11#include <linux/cdev.h>
12#include <linux/smp_lock.h>
13
14#include <asm/uaccess.h>
15#include <asm/cio.h>
16#include <asm/ccwdev.h>
17#include <asm/debug.h>
18#include <asm/diag.h>
19
20#include "vmur.h"

--- 252 unchanged lines hidden (view full) ---

273 * ur interrupt handler, called from the ccw_device layer
274 */
275static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
276 struct irb *irb)
277{
278 struct urdev *urd;
279
280 TRACE("ur_int_handler: intparm=0x%lx cstat=%02x dstat=%02x res=%u\n",
12
13#include <asm/uaccess.h>
14#include <asm/cio.h>
15#include <asm/ccwdev.h>
16#include <asm/debug.h>
17#include <asm/diag.h>
18
19#include "vmur.h"

--- 252 unchanged lines hidden (view full) ---

272 * ur interrupt handler, called from the ccw_device layer
273 */
274static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
275 struct irb *irb)
276{
277 struct urdev *urd;
278
279 TRACE("ur_int_handler: intparm=0x%lx cstat=%02x dstat=%02x res=%u\n",
281 intparm, irb->scsw.cstat, irb->scsw.dstat, irb->scsw.count);
280 intparm, irb->scsw.cmd.cstat, irb->scsw.cmd.dstat,
281 irb->scsw.cmd.count);
282
283 if (!intparm) {
284 TRACE("ur_int_handler: unsolicited interrupt\n");
285 return;
286 }
287 urd = cdev->dev.driver_data;
288 BUG_ON(!urd);
289 /* On special conditions irb is an error pointer */
290 if (IS_ERR(irb))
291 urd->io_request_rc = PTR_ERR(irb);
282
283 if (!intparm) {
284 TRACE("ur_int_handler: unsolicited interrupt\n");
285 return;
286 }
287 urd = cdev->dev.driver_data;
288 BUG_ON(!urd);
289 /* On special conditions irb is an error pointer */
290 if (IS_ERR(irb))
291 urd->io_request_rc = PTR_ERR(irb);
292 else if (irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END))
292 else if (irb->scsw.cmd.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END))
293 urd->io_request_rc = 0;
294 else
295 urd->io_request_rc = -EIO;
296
297 complete(urd->io_done);
298}
299
300/*

--- 363 unchanged lines hidden (view full) ---

664 struct urfile *urf;
665 unsigned short accmode;
666 int rc;
667
668 accmode = file->f_flags & O_ACCMODE;
669
670 if (accmode == O_RDWR)
671 return -EACCES;
293 urd->io_request_rc = 0;
294 else
295 urd->io_request_rc = -EIO;
296
297 complete(urd->io_done);
298}
299
300/*

--- 363 unchanged lines hidden (view full) ---

664 struct urfile *urf;
665 unsigned short accmode;
666 int rc;
667
668 accmode = file->f_flags & O_ACCMODE;
669
670 if (accmode == O_RDWR)
671 return -EACCES;
672 lock_kernel();
672
673 /*
674 * We treat the minor number as the devno of the ur device
675 * to find in the driver tree.
676 */
677 devno = MINOR(file->f_dentry->d_inode->i_rdev);
678
679 urd = urdev_get_from_devno(devno);
673 /*
674 * We treat the minor number as the devno of the ur device
675 * to find in the driver tree.
676 */
677 devno = MINOR(file->f_dentry->d_inode->i_rdev);
678
679 urd = urdev_get_from_devno(devno);
680 if (!urd) {
681 rc = -ENXIO;
682 goto out;
683 }
680 if (!urd)
681 return -ENXIO;
684
685 spin_lock(&urd->open_lock);
686 while (urd->open_flag) {
687 spin_unlock(&urd->open_lock);
688 if (file->f_flags & O_NONBLOCK) {
689 rc = -EBUSY;
690 goto fail_put;
691 }

--- 26 unchanged lines hidden (view full) ---

718 }
719
720 urf->dev_reclen = urd->reclen;
721 rc = get_file_reclen(urd);
722 if (rc < 0)
723 goto fail_urfile_free;
724 urf->file_reclen = rc;
725 file->private_data = urf;
682
683 spin_lock(&urd->open_lock);
684 while (urd->open_flag) {
685 spin_unlock(&urd->open_lock);
686 if (file->f_flags & O_NONBLOCK) {
687 rc = -EBUSY;
688 goto fail_put;
689 }

--- 26 unchanged lines hidden (view full) ---

716 }
717
718 urf->dev_reclen = urd->reclen;
719 rc = get_file_reclen(urd);
720 if (rc < 0)
721 goto fail_urfile_free;
722 urf->file_reclen = rc;
723 file->private_data = urf;
726 unlock_kernel();
727 return 0;
728
729fail_urfile_free:
730 urfile_free(urf);
731fail_unlock:
732 spin_lock(&urd->open_lock);
733 urd->open_flag--;
734 spin_unlock(&urd->open_lock);
735fail_put:
736 urdev_put(urd);
724 return 0;
725
726fail_urfile_free:
727 urfile_free(urf);
728fail_unlock:
729 spin_lock(&urd->open_lock);
730 urd->open_flag--;
731 spin_unlock(&urd->open_lock);
732fail_put:
733 urdev_put(urd);
737out:
738 unlock_kernel();
739 return rc;
740}
741
742static int ur_release(struct inode *inode, struct file *file)
743{
744 struct urfile *urf = file->private_data;
745
746 TRACE("ur_release\n");

--- 294 unchanged lines hidden ---
734 return rc;
735}
736
737static int ur_release(struct inode *inode, struct file *file)
738{
739 struct urfile *urf = file->private_data;
740
741 TRACE("ur_release\n");

--- 294 unchanged lines hidden ---