| 145 | static ssize_t serial_fops_read(struct dfs_file *fd, void *buf, size_t count, off_t *pos) |
| 146 | #else |
| 147 | static ssize_t serial_fops_read(struct dfs_file *fd, void *buf, size_t count) |
| 148 | #endif |
| 149 | { |
| 150 | int size = 0; |
| 151 | rt_device_t device; |
| 152 | int wait_ret; |
| 153 | |
| 154 | device = (rt_device_t)fd->vnode->data; |
| 155 | |
| 156 | do |
| 157 | { |
| 158 | size = rt_device_read(device, -1, buf, count); |
| 159 | if (size <= 0) |
| 160 | { |
| 161 | if (fd->flags & O_NONBLOCK) |
| 162 | { |
| 163 | size = -EAGAIN; |
| 164 | break; |
| 165 | } |
| 166 | |
| 167 | wait_ret = rt_wqueue_wait_interruptible(&(device->wait_queue), 0, RT_WAITING_FOREVER); |
| 168 | if (wait_ret != RT_EOK) |
| 169 | { |
| 170 | break; |
| 171 | } |
| 172 | } |
| 173 | }while (size <= 0); |
| 174 | |
| 175 | if (size < 0) |
| 176 | { |
| 177 | size = 0; |
| 178 | } |
| 179 | return size; |
| 180 | } |
| 181 | |
| 182 | #ifdef RT_USING_DFS_V2 |
| 183 | static ssize_t serial_fops_write(struct dfs_file *fd, const void *buf, size_t count, off_t *pos) |
nothing calls this directly
no test coverage detected