Skip to content

Commit

Permalink
examples: get rpmsg_ctrl from new path
Browse files Browse the repository at this point in the history
Kernel uses rpmsg_ctrl from virtio0.rpmsg_ctrl.0.0 directory.
Add this support without breaking backward compatibility

Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
  • Loading branch information
tnmysh authored and arnopo committed Nov 15, 2022
1 parent 7984199 commit 0a51535
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/linux/rpmsg-echo-test/echo_test.c
Expand Up @@ -257,6 +257,7 @@ int main(int argc, char *argv[])
int opt, charfd, fd;
int ntimes = 1;
char rpmsg_dev[NAME_MAX] = "virtio0.rpmsg-openamp-demo-channel.-1.0";
char rpmsg_ctrl_dev_name[NAME_MAX] = "virtio0.rpmsg_ctrl.0.0";
char rpmsg_char_name[16];
char fpath[2*NAME_MAX];
struct rpmsg_endpoint_info eptinfo = {
Expand Down Expand Up @@ -306,9 +307,15 @@ int main(int argc, char *argv[])
ret = bind_rpmsg_chrdev(rpmsg_dev);
if (ret < 0)
return ret;
charfd = get_rpmsg_chrdev_fd(rpmsg_dev, rpmsg_char_name);
if (charfd < 0)
return charfd;

/* kernel >= 6.0 has new path for rpmsg_ctrl device */
charfd = get_rpmsg_chrdev_fd(rpmsg_ctrl_dev_name, rpmsg_char_name);
if (charfd < 0) {
/* may be kernel is < 6.0 try previous path */
charfd = get_rpmsg_chrdev_fd(rpmsg_dev, rpmsg_char_name);
if (charfd < 0)
return charfd;
}

/* Create endpoint from rpmsg char driver */
PR_DBG("app_rpmsg_create_ept: %s[src=%#x,dst=%#x]\n",
Expand Down

0 comments on commit 0a51535

Please sign in to comment.