incubator-nuttx/openamp/0012-rpmsg-add-new-API-rpde...

101 lines
2.9 KiB
Diff

From a541d9d446e5700fd5a74cf5d8296114023b40fb Mon Sep 17 00:00:00 2001
From: ligd <liguiding1@xiaomi.com>
Date: Fri, 6 Jan 2023 22:57:02 +0800
Subject: [PATCH 2/6] rpmsg: add new API rpdev_release_tx/rx_buffer()
These API used for release tx/rx buffer from rpmsg_device
For case:
get_tx_buffer
close ept
release tx buffer failed
Change-Id: I74f83ff336415ccbe0191e67315ed27a35be3983
Signed-off-by: ligd <liguiding1@xiaomi.com>
---
lib/include/openamp/rpmsg.h | 2 ++
lib/rpmsg/rpmsg.c | 32 ++++++++++++++++++++------------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/lib/include/openamp/rpmsg.h open-amp/lib/include/openamp/rpmsg.h
index fbd7f61..d39a7a4 100644
--- a/lib/include/openamp/rpmsg.h
+++ open-amp/lib/include/openamp/rpmsg.h
@@ -360,6 +360,7 @@ void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf);
* @see rpmsg_hold_rx_buffer
*/
void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf);
+void rpdev_release_rx_buffer(struct rpmsg_device *rdev, void *rxbuf);
/**
* @brief Gets the tx buffer for message payload.
@@ -405,6 +406,7 @@ void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
* @see rpmsg_get_tx_payload_buffer
*/
int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf);
+int rpdev_release_tx_buffer(struct rpmsg_device *rdev, void *txbuf);
/**
* rpmsg_send_offchannel_nocopy() - send a message in tx buffer reserved by
diff --git a/lib/rpmsg/rpmsg.c open-amp/lib/rpmsg/rpmsg.c
index 4e7f7da..93a6282 100644
--- a/lib/rpmsg/rpmsg.c
+++ open-amp/lib/rpmsg/rpmsg.c
@@ -157,34 +157,42 @@ void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
rdev->ops.hold_rx_buffer(rdev, rxbuf);
}
-void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
+void rpdev_release_rx_buffer(struct rpmsg_device *rdev, void *rxbuf)
{
- struct rpmsg_device *rdev;
-
- if (!ept || !ept->rdev || !rxbuf)
+ if (!rdev || !rxbuf)
return;
- rdev = ept->rdev;
-
if (rdev->ops.release_rx_buffer)
rdev->ops.release_rx_buffer(rdev, rxbuf);
}
-int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *buf)
+void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
{
- struct rpmsg_device *rdev;
+ if (!ept)
+ return;
- if (!ept || !ept->rdev || !buf)
- return RPMSG_ERR_PARAM;
+ rpdev_release_rx_buffer(ept->rdev, rxbuf);
+}
- rdev = ept->rdev;
+int rpdev_release_tx_buffer(struct rpmsg_device *rdev, void *txbuf)
+{
+ if (!rdev || !txbuf)
+ return RPMSG_ERR_PERM;
if (rdev->ops.release_tx_buffer)
- return rdev->ops.release_tx_buffer(rdev, buf);
+ return rdev->ops.release_tx_buffer(rdev, txbuf);
return RPMSG_ERR_PERM;
}
+int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf)
+{
+ if (!ept)
+ return RPMSG_ERR_PARAM;
+
+ return rpdev_release_tx_buffer(ept->rdev, txbuf);
+}
+
void *rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept,
uint32_t *len, int wait)
{
--
2.25.1