Skip to content

Commit 52fd48f

Browse files
ComerLatermessigogogo
authored andcommitted
[fixed]serial_v2.c兼容DFS_V2接口 (RT-Thread#9153)
1 parent 24b8b2a commit 52fd48f

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

components/drivers/serial/serial_v2.c

+16-11
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ static int serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
118118
return rt_device_control(device, cmd, args);
119119
}
120120

121-
static int serial_fops_read(struct dfs_file *fd, void *buf, size_t count)
121+
#ifdef RT_USING_DFS_V2
122+
static ssize_t serial_fops_read(struct dfs_file *fd, void *buf, size_t count, off_t *pos)
123+
#else
124+
static ssize_t serial_fops_read(struct dfs_file *fd, void *buf, size_t count)
125+
#endif
122126
{
123127
int size = 0;
124128
rt_device_t device;
@@ -143,7 +147,11 @@ static int serial_fops_read(struct dfs_file *fd, void *buf, size_t count)
143147
return size;
144148
}
145149

146-
static int serial_fops_write(struct dfs_file *fd, const void *buf, size_t count)
150+
#ifdef RT_USING_DFS_V2
151+
static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count, off_t *pos)
152+
#else
153+
static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count)
154+
#endif
147155
{
148156
rt_device_t device;
149157

@@ -186,15 +194,12 @@ static int serial_fops_poll(struct dfs_file *fd, struct rt_pollreq *req)
186194

187195
const static struct dfs_file_ops _serial_fops =
188196
{
189-
serial_fops_open,
190-
serial_fops_close,
191-
serial_fops_ioctl,
192-
serial_fops_read,
193-
serial_fops_write,
194-
RT_NULL, /* flush */
195-
RT_NULL, /* lseek */
196-
RT_NULL, /* getdents */
197-
serial_fops_poll,
197+
.open = serial_fops_open,
198+
.close = serial_fops_close,
199+
.ioctl = serial_fops_ioctl,
200+
.read = serial_fops_read,
201+
.write = serial_fops_write,
202+
.poll = serial_fops_poll,
198203
};
199204
#endif /* RT_USING_POSIX_STDIO */
200205

0 commit comments

Comments
 (0)