| 198 | ****************************************************************************/ |
| 199 | |
| 200 | static int rpmsgdev_open(FAR struct file *filep) |
| 201 | { |
| 202 | FAR struct rpmsgdev_s *dev; |
| 203 | FAR struct rpmsgdev_priv_s *priv; |
| 204 | struct rpmsgdev_open_s msg; |
| 205 | int ret; |
| 206 | |
| 207 | /* Get the mountpoint inode reference from the file structure and the |
| 208 | * mountpoint private data from the inode structure |
| 209 | */ |
| 210 | |
| 211 | dev = filep->f_inode->i_private; |
| 212 | DEBUGASSERT(dev != NULL); |
| 213 | |
| 214 | priv = kmm_zalloc(sizeof(*priv)); |
| 215 | if (priv == NULL) |
| 216 | { |
| 217 | return -ENOMEM; |
| 218 | } |
| 219 | |
| 220 | /* Try to open the device in the remote cpu, open with O_NONBLOCK |
| 221 | * by default to avoid the server rptun thread blocked in read/write |
| 222 | * operations. |
| 223 | */ |
| 224 | |
| 225 | msg.flags = filep->f_oflags | O_NONBLOCK; |
| 226 | ret = rpmsgdev_send_recv(dev, RPMSGDEV_OPEN, true, &msg.header, |
| 227 | sizeof(msg), NULL); |
| 228 | if (ret < 0) |
| 229 | { |
| 230 | rpmsgdeverr("open failed, ret=%d\n", ret); |
| 231 | kmm_free(priv); |
| 232 | return ret; |
| 233 | } |
| 234 | |
| 235 | priv->filep = msg.filep; |
| 236 | priv->nonblock = (filep->f_oflags & O_NONBLOCK) != 0; |
| 237 | |
| 238 | /* Attach the private date to the struct file instance */ |
| 239 | |
| 240 | filep->f_priv = priv; |
| 241 | |
| 242 | return ret; |
| 243 | } |
| 244 | |
| 245 | /**************************************************************************** |
| 246 | * Name: rpmsgdev_close |
nothing calls this directly
no test coverage detected