[drivers][serial] ioctl add F_SETFL cmd (#5876)

This commit is contained in:
Tangyuxin 2022-04-26 13:13:51 +08:00 committed by GitHub
parent 7c99148f78
commit 7f1157e0de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -115,6 +115,8 @@ static int serial_fops_close(struct dfs_fd *fd)
static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
{
rt_device_t device;
int flags = (int)(rt_base_t)args;
int mask = O_NONBLOCK | O_APPEND;
device = (rt_device_t)fd->data;
switch (cmd)
@ -123,6 +125,11 @@ static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
break;
case FIONWRITE:
break;
case F_SETFL:
flags &= mask;
fd->flags &= ~mask;
fd->flags |= flags;
break;
}
return rt_device_control(device, cmd, args);

View File

@ -94,6 +94,8 @@ static int serial_fops_close(struct dfs_fd *fd)
static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
{
rt_device_t device;
int flags = (int)(rt_base_t)args;
int mask = O_NONBLOCK | O_APPEND;
device = (rt_device_t)fd->data;
switch (cmd)
@ -102,6 +104,11 @@ static int serial_fops_ioctl(struct dfs_fd *fd, int cmd, void *args)
break;
case FIONWRITE:
break;
case F_SETFL:
flags &= mask;
fd->flags &= ~mask;
fd->flags |= flags;
break;
}
return rt_device_control(device, cmd, args);