Commit bbd18809 authored by Bjorn Andersson's avatar Bjorn Andersson

rpmsg: Support drivers without primary endpoint

Some types of rpmsg drivers does not have a primary endpoint to tie
their existence upon, but wishes to create and destroy endpoints
dynamically, e.g. based on user interactions.

Allow rpmsg drivers to omit a driver callback to signal this case and
make the probe path not create a primary endpoint in this case.
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent e9506047
...@@ -347,27 +347,30 @@ static int rpmsg_dev_probe(struct device *dev) ...@@ -347,27 +347,30 @@ static int rpmsg_dev_probe(struct device *dev)
struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_device *rpdev = to_rpmsg_device(dev);
struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver);
struct rpmsg_channel_info chinfo = {}; struct rpmsg_channel_info chinfo = {};
struct rpmsg_endpoint *ept; struct rpmsg_endpoint *ept = NULL;
int err; int err;
strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); if (rpdrv->callback) {
chinfo.src = rpdev->src; strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE);
chinfo.dst = RPMSG_ADDR_ANY; chinfo.src = rpdev->src;
chinfo.dst = RPMSG_ADDR_ANY;
ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo); ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo);
if (!ept) { if (!ept) {
dev_err(dev, "failed to create endpoint\n"); dev_err(dev, "failed to create endpoint\n");
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
rpdev->ept = ept; rpdev->ept = ept;
rpdev->src = ept->addr; rpdev->src = ept->addr;
}
err = rpdrv->probe(rpdev); err = rpdrv->probe(rpdev);
if (err) { if (err) {
dev_err(dev, "%s: failed: %d\n", __func__, err); dev_err(dev, "%s: failed: %d\n", __func__, err);
rpmsg_destroy_ept(ept); if (ept)
rpmsg_destroy_ept(ept);
goto out; goto out;
} }
...@@ -388,7 +391,8 @@ static int rpmsg_dev_remove(struct device *dev) ...@@ -388,7 +391,8 @@ static int rpmsg_dev_remove(struct device *dev)
rpdrv->remove(rpdev); rpdrv->remove(rpdev);
rpmsg_destroy_ept(rpdev->ept); if (rpdev->ept)
rpmsg_destroy_ept(rpdev->ept);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment