diff options
author | Michael Holzheu <holzheu@linux.vnet.ibm.com> | 2013-06-06 03:49:09 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-06-26 15:10:11 -0400 |
commit | 7a9cc6e18b8fe751a41349b188dd468a8317192a (patch) | |
tree | 0fe5e8f7afde1186a03ee8dd48f4226bc1f5c4a1 /drivers/s390/cio/chsc_sch.c | |
parent | 64150adf89df2ed165d6760f414fa6df07d22628 (diff) |
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/cio/chsc_sch.c')
-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 190fc844d814..5fe9f8c4b4fb 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, | |||
847 | } | 847 | } |
848 | } | 848 | } |
849 | 849 | ||
850 | static atomic_t chsc_ready_for_use = ATOMIC_INIT(1); | ||
851 | |||
852 | static int chsc_open(struct inode *inode, struct file *file) | ||
853 | { | ||
854 | if (!atomic_dec_and_test(&chsc_ready_for_use)) { | ||
855 | atomic_inc(&chsc_ready_for_use); | ||
856 | return -EBUSY; | ||
857 | } | ||
858 | return nonseekable_open(inode, file); | ||
859 | } | ||
860 | |||
861 | static int chsc_release(struct inode *inode, struct file *filp) | ||
862 | { | ||
863 | atomic_inc(&chsc_ready_for_use); | ||
864 | return 0; | ||
865 | } | ||
866 | |||
850 | static const struct file_operations chsc_fops = { | 867 | static const struct file_operations chsc_fops = { |
851 | .owner = THIS_MODULE, | 868 | .owner = THIS_MODULE, |
852 | .open = nonseekable_open, | 869 | .open = chsc_open, |
870 | .release = chsc_release, | ||
853 | .unlocked_ioctl = chsc_ioctl, | 871 | .unlocked_ioctl = chsc_ioctl, |
854 | .compat_ioctl = chsc_ioctl, | 872 | .compat_ioctl = chsc_ioctl, |
855 | .llseek = no_llseek, | 873 | .llseek = no_llseek, |