From ffdf5cf0dee8fa1539e078dc60bc0c233263e4c5 Mon Sep 17 00:00:00 2001 From: latercomer Date: Mon, 8 Jul 2024 17:18:22 +0800 Subject: [PATCH] =?UTF-8?q?[fixed]serial=5Fv2.c=E5=85=BC=E5=AE=B9DFS=5FV2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/drivers/serial/serial_v2.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/components/drivers/serial/serial_v2.c b/components/drivers/serial/serial_v2.c index d7576dbed87..111bfbca01f 100644 --- a/components/drivers/serial/serial_v2.c +++ b/components/drivers/serial/serial_v2.c @@ -118,7 +118,11 @@ static int serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args) return rt_device_control(device, cmd, args); } -static int serial_fops_read(struct dfs_file *fd, void *buf, size_t count) +#ifdef RT_USING_DFS_V2 +static ssize_t serial_fops_read(struct dfs_file *fd, void *buf, size_t count, off_t *pos) +#else +static ssize_t serial_fops_read(struct dfs_file *fd, void *buf, size_t count) +#endif { int size = 0; rt_device_t device; @@ -143,7 +147,11 @@ static int serial_fops_read(struct dfs_file *fd, void *buf, size_t count) return size; } -static int serial_fops_write(struct dfs_file *fd, const void *buf, size_t count) +#ifdef RT_USING_DFS_V2 +static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count, off_t *pos) +#else +static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count) +#endif { rt_device_t device; @@ -186,15 +194,12 @@ static int serial_fops_poll(struct dfs_file *fd, struct rt_pollreq *req) const static struct dfs_file_ops _serial_fops = { - serial_fops_open, - serial_fops_close, - serial_fops_ioctl, - serial_fops_read, - serial_fops_write, - RT_NULL, /* flush */ - RT_NULL, /* lseek */ - RT_NULL, /* getdents */ - serial_fops_poll, + .open = serial_fops_open, + .close = serial_fops_close, + .ioctl = serial_fops_ioctl, + .read = serial_fops_read, + .write = serial_fops_write, + .poll = serial_fops_poll, }; #endif /* RT_USING_POSIX_STDIO */