From c98bbaef9dc6d49b05c83e5a91b7c857eeb985c6 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Tue, 2 Apr 2024 17:33:29 +0200 Subject: [PATCH] rpmsg_virtio: fix initialized notify_wait_cb The rvdev->notify_wait_cb is not initialized to NULL if not set by the user. Initialize it to NULL and provide an API for the application to set it. Signed-off-by: Arnaud Pouliquen --- lib/include/openamp/rpmsg_virtio.h | 14 ++++++++++++++ lib/rpmsg/rpmsg_virtio.c | 1 + 2 files changed, 15 insertions(+) diff --git a/lib/include/openamp/rpmsg_virtio.h b/lib/include/openamp/rpmsg_virtio.h index 752be7762..18c73b710 100644 --- a/lib/include/openamp/rpmsg_virtio.h +++ b/lib/include/openamp/rpmsg_virtio.h @@ -127,6 +127,20 @@ __deprecated static inline int deprecated_rpmsg_slave(void) return RPMSG_REMOTE; } +/** + * @brief Set the virtio callback to manage the wait for TX buffer availability. + * + * @param rvdev Pointer to rpmsg virtio device. + * @param notify_wait_cb Callback handler to wait buffer notification. + * + * @return RPMSG_REMOTE or RPMSG_HOST + */ +static inline void rpmsg_virtio_set_wait_cb(struct rpmsg_virtio_device *rvdev, + rpmsg_virtio_notify_wait_cb notify_wait_cb) +{ + rvdev->notify_wait_cb = notify_wait_cb; +} + /** * @brief Get rpmsg virtio device role. * diff --git a/lib/rpmsg/rpmsg_virtio.c b/lib/rpmsg/rpmsg_virtio.c index 1a9d0bfaa..e68f758a0 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ b/lib/rpmsg/rpmsg_virtio.c @@ -821,6 +821,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, return RPMSG_ERR_PARAM; rdev = &rvdev->rdev; + rvdev->notify_wait_cb = NULL; memset(rdev, 0, sizeof(*rdev)); metal_mutex_init(&rdev->lock); rvdev->vdev = vdev;