Skip to content

Commit 9753e12

Browse files
arnopoandersson
authored andcommitted
rpmsg: core: Add channel creation internal API
Add the channel creation API as a first step to be able to define the name service announcement as a rpmsg driver independent from the RPMsg virtio bus. Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Link: https://lore.kernel.org/r/20201120214245.172963-6-mathieu.poirier@linaro.org Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
1 parent 77d3729 commit 9753e12

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

drivers/rpmsg/rpmsg_core.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,50 @@
2020

2121
#include "rpmsg_internal.h"
2222

23+
/**
24+
* rpmsg_create_channel() - create a new rpmsg channel
25+
* using its name and address info.
26+
* @rpdev: rpmsg device
27+
* @chinfo: channel_info to bind
28+
*
29+
* Returns a pointer to the new rpmsg device on success, or NULL on error.
30+
*/
31+
struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev,
32+
struct rpmsg_channel_info *chinfo)
33+
{
34+
if (WARN_ON(!rpdev))
35+
return NULL;
36+
if (!rpdev->ops || !rpdev->ops->create_channel) {
37+
dev_err(&rpdev->dev, "no create_channel ops found\n");
38+
return NULL;
39+
}
40+
41+
return rpdev->ops->create_channel(rpdev, chinfo);
42+
}
43+
EXPORT_SYMBOL(rpmsg_create_channel);
44+
45+
/**
46+
* rpmsg_release_channel() - release a rpmsg channel
47+
* using its name and address info.
48+
* @rpdev: rpmsg device
49+
* @chinfo: channel_info to bind
50+
*
51+
* Returns 0 on success or an appropriate error value.
52+
*/
53+
int rpmsg_release_channel(struct rpmsg_device *rpdev,
54+
struct rpmsg_channel_info *chinfo)
55+
{
56+
if (WARN_ON(!rpdev))
57+
return -EINVAL;
58+
if (!rpdev->ops || !rpdev->ops->release_channel) {
59+
dev_err(&rpdev->dev, "no release_channel ops found\n");
60+
return -ENXIO;
61+
}
62+
63+
return rpdev->ops->release_channel(rpdev, chinfo);
64+
}
65+
EXPORT_SYMBOL(rpmsg_release_channel);
66+
2367
/**
2468
* rpmsg_create_ept() - create a new rpmsg_endpoint
2569
* @rpdev: rpmsg channel device

drivers/rpmsg/rpmsg_internal.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
/**
2222
* struct rpmsg_device_ops - indirection table for the rpmsg_device operations
23+
* @create_channel: create backend-specific channel, optional
24+
* @release_channel: release backend-specific channel, optional
2325
* @create_ept: create backend-specific endpoint, required
2426
* @announce_create: announce presence of new channel, optional
2527
* @announce_destroy: announce destruction of channel, optional
@@ -29,6 +31,10 @@
2931
* advertise new channels implicitly by creating the endpoints.
3032
*/
3133
struct rpmsg_device_ops {
34+
struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev,
35+
struct rpmsg_channel_info *chinfo);
36+
int (*release_channel)(struct rpmsg_device *rpdev,
37+
struct rpmsg_channel_info *chinfo);
3238
struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev,
3339
rpmsg_rx_cb_t cb, void *priv,
3440
struct rpmsg_channel_info chinfo);
@@ -75,6 +81,10 @@ int rpmsg_unregister_device(struct device *parent,
7581
struct device *rpmsg_find_device(struct device *parent,
7682
struct rpmsg_channel_info *chinfo);
7783

84+
struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev,
85+
struct rpmsg_channel_info *chinfo);
86+
int rpmsg_release_channel(struct rpmsg_device *rpdev,
87+
struct rpmsg_channel_info *chinfo);
7888
/**
7989
* rpmsg_chrdev_register_device() - register chrdev device based on rpdev
8090
* @rpdev: prepared rpdev to be used for creating endpoints

0 commit comments

Comments
 (0)