diff options
author | Michael Holzheu <holzheu@linux.vnet.ibm.com> | 2013-06-06 07:49:09 (GMT) |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-06-26 19:10:11 (GMT) |
commit | 7a9cc6e18b8fe751a41349b188dd468a8317192a (patch) | |
tree | 0fe5e8f7afde1186a03ee8dd48f4226bc1f5c4a1 /drivers/s390 | |
parent | 64150adf89df2ed165d6760f414fa6df07d22628 (diff) | |
download | linux-7a9cc6e18b8fe751a41349b188dd468a8317192a.tar.xz |
s390/cio: Make /dev/chsc a single-open device
In order to allow serialization of dynamic I/O with this patch
the /dev/chsc character device can only be accessed by one
single opener. Any subsequent open calls are rejected with EBUSY.
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/cio/chsc_sch.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c index 190fc84..5fe9f8c 100644 --- a/drivers/s390/cio/chsc_sch.c +++ b/drivers/s390/cio/chsc_sch.c @@ -847,9 +847,27 @@ static long chsc_ioctl(struct file *filp, unsigned int cmd, } } +static atomic_t chsc_ready_for_use = ATOMIC_INIT(1); + +static int chsc_open(struct inode *inode, struct file *file) +{ + if (!atomic_dec_and_test(&chsc_ready_for_use)) { + atomic_inc(&chsc_ready_for_use); + return -EBUSY; + } + return nonseekable_open(inode, file); +} + +static int chsc_release(struct inode *inode, struct file *filp) +{ + atomic_inc(&chsc_ready_for_use); + return 0; +} + static const struct file_operations chsc_fops = { .owner = THIS_MODULE, - .open = nonseekable_open, + .open = chsc_open, + .release = chsc_release, .unlocked_ioctl = chsc_ioctl, .compat_ioctl = chsc_ioctl, .llseek = no_llseek, |