mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
samples: rpmsg: Add MTU size info
RPMsg MTU size can be variable now and no longer hardcoded to 512 bytes. Add log to the sample driver that prints current MTU size of the rpmsg buffer. Signed-off-by: Tanmay Shah <[email protected]> Acked-by: Arnaud Pouliquen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
This commit is contained in:
committed by
Mathieu Poirier
parent
079844f735
commit
1029c89baf
@@ -52,6 +52,7 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
|
||||
{
|
||||
int ret;
|
||||
struct instance_data *idata;
|
||||
ssize_t mtu, msg_len;
|
||||
|
||||
dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n",
|
||||
rpdev->src, rpdev->dst);
|
||||
@@ -62,8 +63,25 @@ static int rpmsg_sample_probe(struct rpmsg_device *rpdev)
|
||||
|
||||
dev_set_drvdata(&rpdev->dev, idata);
|
||||
|
||||
mtu = rpmsg_get_mtu(rpdev->ept);
|
||||
if (mtu < 0) {
|
||||
dev_warn(&rpdev->dev, "invalid rpmsg MTU size = %ld\n", mtu);
|
||||
return mtu;
|
||||
}
|
||||
|
||||
dev_info(&rpdev->dev, "rpmsg MTU size = %ld\n", mtu);
|
||||
|
||||
msg_len = strlen(MSG);
|
||||
/* make sure our message fits in a single rpmsg buffer */
|
||||
if (msg_len > mtu) {
|
||||
dev_err(&rpdev->dev,
|
||||
"message size %zu exceeds rpmsg MTU size %ld\n",
|
||||
strlen(MSG), mtu);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
/* send a message to our remote processor */
|
||||
ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG));
|
||||
ret = rpmsg_send(rpdev->ept, MSG, msg_len);
|
||||
if (ret) {
|
||||
dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user