mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
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>
This commit is contained in:
committed by
Bjorn Andersson
parent
77d372989d
commit
9753e12cd3
@@ -20,6 +20,50 @@
|
|||||||
|
|
||||||
#include "rpmsg_internal.h"
|
#include "rpmsg_internal.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rpmsg_create_channel() - create a new rpmsg channel
|
||||||
|
* using its name and address info.
|
||||||
|
* @rpdev: rpmsg device
|
||||||
|
* @chinfo: channel_info to bind
|
||||||
|
*
|
||||||
|
* Returns a pointer to the new rpmsg device on success, or NULL on error.
|
||||||
|
*/
|
||||||
|
struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev,
|
||||||
|
struct rpmsg_channel_info *chinfo)
|
||||||
|
{
|
||||||
|
if (WARN_ON(!rpdev))
|
||||||
|
return NULL;
|
||||||
|
if (!rpdev->ops || !rpdev->ops->create_channel) {
|
||||||
|
dev_err(&rpdev->dev, "no create_channel ops found\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rpdev->ops->create_channel(rpdev, chinfo);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(rpmsg_create_channel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rpmsg_release_channel() - release a rpmsg channel
|
||||||
|
* using its name and address info.
|
||||||
|
* @rpdev: rpmsg device
|
||||||
|
* @chinfo: channel_info to bind
|
||||||
|
*
|
||||||
|
* Returns 0 on success or an appropriate error value.
|
||||||
|
*/
|
||||||
|
int rpmsg_release_channel(struct rpmsg_device *rpdev,
|
||||||
|
struct rpmsg_channel_info *chinfo)
|
||||||
|
{
|
||||||
|
if (WARN_ON(!rpdev))
|
||||||
|
return -EINVAL;
|
||||||
|
if (!rpdev->ops || !rpdev->ops->release_channel) {
|
||||||
|
dev_err(&rpdev->dev, "no release_channel ops found\n");
|
||||||
|
return -ENXIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rpdev->ops->release_channel(rpdev, chinfo);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(rpmsg_release_channel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rpmsg_create_ept() - create a new rpmsg_endpoint
|
* rpmsg_create_ept() - create a new rpmsg_endpoint
|
||||||
* @rpdev: rpmsg channel device
|
* @rpdev: rpmsg channel device
|
||||||
|
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* struct rpmsg_device_ops - indirection table for the rpmsg_device operations
|
* struct rpmsg_device_ops - indirection table for the rpmsg_device operations
|
||||||
|
* @create_channel: create backend-specific channel, optional
|
||||||
|
* @release_channel: release backend-specific channel, optional
|
||||||
* @create_ept: create backend-specific endpoint, required
|
* @create_ept: create backend-specific endpoint, required
|
||||||
* @announce_create: announce presence of new channel, optional
|
* @announce_create: announce presence of new channel, optional
|
||||||
* @announce_destroy: announce destruction of channel, optional
|
* @announce_destroy: announce destruction of channel, optional
|
||||||
@@ -29,6 +31,10 @@
|
|||||||
* advertise new channels implicitly by creating the endpoints.
|
* advertise new channels implicitly by creating the endpoints.
|
||||||
*/
|
*/
|
||||||
struct rpmsg_device_ops {
|
struct rpmsg_device_ops {
|
||||||
|
struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev,
|
||||||
|
struct rpmsg_channel_info *chinfo);
|
||||||
|
int (*release_channel)(struct rpmsg_device *rpdev,
|
||||||
|
struct rpmsg_channel_info *chinfo);
|
||||||
struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev,
|
struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev,
|
||||||
rpmsg_rx_cb_t cb, void *priv,
|
rpmsg_rx_cb_t cb, void *priv,
|
||||||
struct rpmsg_channel_info chinfo);
|
struct rpmsg_channel_info chinfo);
|
||||||
@@ -75,6 +81,10 @@ int rpmsg_unregister_device(struct device *parent,
|
|||||||
struct device *rpmsg_find_device(struct device *parent,
|
struct device *rpmsg_find_device(struct device *parent,
|
||||||
struct rpmsg_channel_info *chinfo);
|
struct rpmsg_channel_info *chinfo);
|
||||||
|
|
||||||
|
struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev,
|
||||||
|
struct rpmsg_channel_info *chinfo);
|
||||||
|
int rpmsg_release_channel(struct rpmsg_device *rpdev,
|
||||||
|
struct rpmsg_channel_info *chinfo);
|
||||||
/**
|
/**
|
||||||
* rpmsg_chrdev_register_device() - register chrdev device based on rpdev
|
* rpmsg_chrdev_register_device() - register chrdev device based on rpdev
|
||||||
* @rpdev: prepared rpdev to be used for creating endpoints
|
* @rpdev: prepared rpdev to be used for creating endpoints
|
||||||
|
Reference in New Issue
Block a user