mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 00:36:42 +07:00
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>
This commit is contained in:
parent
73e18f7c0b
commit
9a779bc149
@ -106,16 +106,8 @@ static long serial2002_tty_ioctl(struct file *f, unsigned int op,
|
|||||||
|
|
||||||
static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
|
static int serial2002_tty_write(struct file *f, unsigned char *buf, int count)
|
||||||
{
|
{
|
||||||
const char __user *p = (__force const char __user *)buf;
|
loff_t pos = 0;
|
||||||
int result;
|
return kernel_write(f, buf, count, &pos);
|
||||||
loff_t offset = 0;
|
|
||||||
mm_segment_t oldfs;
|
|
||||||
|
|
||||||
oldfs = get_fs();
|
|
||||||
set_fs(KERNEL_DS);
|
|
||||||
result = __vfs_write(f, p, count, &offset);
|
|
||||||
set_fs(oldfs);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
|
static void serial2002_tty_read_poll_wait(struct file *f, int timeout)
|
||||||
@ -148,19 +140,14 @@ static int serial2002_tty_read(struct file *f, int timeout)
|
|||||||
{
|
{
|
||||||
unsigned char ch;
|
unsigned char ch;
|
||||||
int result;
|
int result;
|
||||||
|
loff_t pos = 0;
|
||||||
|
|
||||||
result = -1;
|
result = -1;
|
||||||
if (!IS_ERR(f)) {
|
if (!IS_ERR(f)) {
|
||||||
mm_segment_t oldfs;
|
|
||||||
char __user *p = (__force char __user *)&ch;
|
|
||||||
loff_t offset = 0;
|
|
||||||
|
|
||||||
oldfs = get_fs();
|
|
||||||
set_fs(KERNEL_DS);
|
|
||||||
if (f->f_op->poll) {
|
if (f->f_op->poll) {
|
||||||
serial2002_tty_read_poll_wait(f, timeout);
|
serial2002_tty_read_poll_wait(f, timeout);
|
||||||
|
|
||||||
if (__vfs_read(f, p, 1, &offset) == 1)
|
if (kernel_read(f, &ch, 1, &pos) == 1)
|
||||||
result = ch;
|
result = ch;
|
||||||
} else {
|
} else {
|
||||||
/* Device does not support poll, busy wait */
|
/* Device does not support poll, busy wait */
|
||||||
@ -171,14 +158,13 @@ static int serial2002_tty_read(struct file *f, int timeout)
|
|||||||
if (retries >= timeout)
|
if (retries >= timeout)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (__vfs_read(f, p, 1, &offset) == 1) {
|
if (kernel_read(f, &ch, 1, &pos) == 1) {
|
||||||
result = ch;
|
result = ch;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep_range(100, 1000);
|
usleep_range(100, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_fs(oldfs);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user