Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael Holzheu and committed by
Martin Schwidefsky
7a9cc6e1 64150adf

+19 -1
+19 -1
drivers/s390/cio/chsc_sch.c
··· 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 867 static const struct file_operations chsc_fops = { 851 868 .owner = THIS_MODULE, 852 - .open = nonseekable_open, 869 + .open = chsc_open, 870 + .release = chsc_release, 853 871 .unlocked_ioctl = chsc_ioctl, 854 872 .compat_ioctl = chsc_ioctl, 855 873 .llseek = no_llseek,