mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 03:45:50 +08:00
drivers/rpmsg_port: support release the rx buffer in ept->cb
Now we can release the rx buffer in ept->cb, ept->cb should copy the rx buffer it's private buffer and then return RPMSG_SUCCESS_BUFFER_RETURNED. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
59259eb7f2
commit
16763e4c67
@@ -406,7 +406,7 @@ static void rpmsg_port_rx_callback(FAR struct rpmsg_port_s *port,
|
|||||||
FAR struct rpmsg_hdr *rphdr = (FAR struct rpmsg_hdr *)hdr->buf;
|
FAR struct rpmsg_hdr *rphdr = (FAR struct rpmsg_hdr *)hdr->buf;
|
||||||
FAR void *data = RPMSG_LOCATE_DATA(rphdr);
|
FAR void *data = RPMSG_LOCATE_DATA(rphdr);
|
||||||
FAR struct rpmsg_endpoint *ept;
|
FAR struct rpmsg_endpoint *ept;
|
||||||
int status;
|
int status = 0;
|
||||||
|
|
||||||
metal_mutex_acquire(&rdev->lock);
|
metal_mutex_acquire(&rdev->lock);
|
||||||
ept = rpmsg_get_ept_from_addr(rdev, rphdr->dst);
|
ept = rpmsg_get_ept_from_addr(rdev, rphdr->dst);
|
||||||
@@ -422,13 +422,17 @@ static void rpmsg_port_rx_callback(FAR struct rpmsg_port_s *port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
status = ept->cb(ept, data, rphdr->len, rphdr->src, ept->priv);
|
status = ept->cb(ept, data, rphdr->len, rphdr->src, ept->priv);
|
||||||
if (status < 0)
|
if (status < 0 && status != RPMSG_SUCCESS_BUFFER_RELEASED)
|
||||||
{
|
{
|
||||||
RPMSG_ASSERT(0, "unexpected callback status\n");
|
RPMSG_ASSERT(0, "unexpected callback status\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rpmsg_port_release_rx_buffer(rdev, data);
|
if (status != RPMSG_SUCCESS_BUFFER_RELEASED)
|
||||||
|
{
|
||||||
|
rpmsg_port_release_rx_buffer(rdev, data);
|
||||||
|
}
|
||||||
|
|
||||||
metal_mutex_acquire(&rdev->lock);
|
metal_mutex_acquire(&rdev->lock);
|
||||||
rpmsg_ept_decref(ept);
|
rpmsg_ept_decref(ept);
|
||||||
metal_mutex_release(&rdev->lock);
|
metal_mutex_release(&rdev->lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user