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

serial2002: switch serial2002_tty_write to kernel_{read/write}

Instead of playing games with the address limit. This also gains
us proper usage of the write counter, time stamp updates and kvec
validation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Christoph Hellwig and committed by
Al Viro
9a779bc1 73e18f7c

+5 -19
+5 -19
drivers/staging/comedi/drivers/serial2002.c
··· 106 106 107 107 static int serial2002_tty_write(struct file *f, unsigned char *buf, int count) 108 108 { 109 - const char __user *p = (__force const char __user *)buf; 110 - int result; 111 - loff_t offset = 0; 112 - mm_segment_t oldfs; 113 - 114 - oldfs = get_fs(); 115 - set_fs(KERNEL_DS); 116 - result = __vfs_write(f, p, count, &offset); 117 - set_fs(oldfs); 118 - return result; 109 + loff_t pos = 0; 110 + return kernel_write(f, buf, count, &pos); 119 111 } 120 112 121 113 static void serial2002_tty_read_poll_wait(struct file *f, int timeout) ··· 140 148 { 141 149 unsigned char ch; 142 150 int result; 151 + loff_t pos = 0; 143 152 144 153 result = -1; 145 154 if (!IS_ERR(f)) { 146 - mm_segment_t oldfs; 147 - char __user *p = (__force char __user *)&ch; 148 - loff_t offset = 0; 149 - 150 - oldfs = get_fs(); 151 - set_fs(KERNEL_DS); 152 155 if (f->f_op->poll) { 153 156 serial2002_tty_read_poll_wait(f, timeout); 154 157 155 - if (__vfs_read(f, p, 1, &offset) == 1) 158 + if (kernel_read(f, &ch, 1, &pos) == 1) 156 159 result = ch; 157 160 } else { 158 161 /* Device does not support poll, busy wait */ ··· 158 171 if (retries >= timeout) 159 172 break; 160 173 161 - if (__vfs_read(f, p, 1, &offset) == 1) { 174 + if (kernel_read(f, &ch, 1, &pos) == 1) { 162 175 result = ch; 163 176 break; 164 177 } 165 178 usleep_range(100, 1000); 166 179 } 167 180 } 168 - set_fs(oldfs); 169 181 } 170 182 return result; 171 183 }