// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2021 STMicroelectronics - All Rights Reserved * * The rpmsg tty driver implements serial communication on the RPMsg bus to makes * possible for user-space programs to send and receive rpmsg messages as a standard * tty protocol. * * The remote processor can instantiate a new tty by requesting a "rpmsg-tty" RPMsg service. * The "rpmsg-tty" service is directly used for data exchange. No flow control is implemented yet.
*/
struct rpmsg_tty_port { struct tty_port port; /* TTY port data */ int id; /* TTY rpmsg index */ struct rpmsg_device *rpdev; /* rpmsg device */
};
staticint rpmsg_tty_cb(struct rpmsg_device *rpdev, void *data, int len, void *priv, u32 src)
{ struct rpmsg_tty_port *cport = dev_get_drvdata(&rpdev->dev); int copied;
if (!len) return -EINVAL;
copied = tty_insert_flip_string(&cport->port, data, len); if (copied != len)
dev_err_ratelimited(&rpdev->dev, "Trunc buffer: available space is %d\n", copied);
tty_flip_buffer_push(&cport->port);
msg_max_size = rpmsg_get_mtu(rpdev->ept); if (msg_max_size < 0) return msg_max_size;
msg_size = min_t(unsignedint, len, msg_max_size);
/* * Use rpmsg_trysend instead of rpmsg_send to send the message so the caller is not * hung until a rpmsg buffer is available. In such case rpmsg_trysend returns -ENOMEM.
*/
ret = rpmsg_trysend(rpdev->ept, (void *)buf, msg_size); if (ret) {
dev_dbg_ratelimited(&rpdev->dev, "rpmsg_send failed: %d\n", ret); return ret;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.