Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Arnaud Pouliquen and committed by
Bjorn Andersson
9753e12c 77d37298

+54
+44
drivers/rpmsg/rpmsg_core.c
··· 21 21 #include "rpmsg_internal.h" 22 22 23 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 + 67 + /** 24 68 * rpmsg_create_ept() - create a new rpmsg_endpoint 25 69 * @rpdev: rpmsg channel device 26 70 * @cb: rx callback handler
+10
drivers/rpmsg/rpmsg_internal.h
··· 20 20 21 21 /** 22 22 * 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 23 25 * @create_ept: create backend-specific endpoint, required 24 26 * @announce_create: announce presence of new channel, optional 25 27 * @announce_destroy: announce destruction of channel, optional ··· 31 29 * advertise new channels implicitly by creating the endpoints. 32 30 */ 33 31 struct rpmsg_device_ops { 32 + struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev, 33 + struct rpmsg_channel_info *chinfo); 34 + int (*release_channel)(struct rpmsg_device *rpdev, 35 + struct rpmsg_channel_info *chinfo); 34 36 struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev, 35 37 rpmsg_rx_cb_t cb, void *priv, 36 38 struct rpmsg_channel_info chinfo); ··· 81 75 struct device *rpmsg_find_device(struct device *parent, 82 76 struct rpmsg_channel_info *chinfo); 83 77 78 + struct rpmsg_device *rpmsg_create_channel(struct rpmsg_device *rpdev, 79 + struct rpmsg_channel_info *chinfo); 80 + int rpmsg_release_channel(struct rpmsg_device *rpdev, 81 + struct rpmsg_channel_info *chinfo); 84 82 /** 85 83 * rpmsg_chrdev_register_device() - register chrdev device based on rpdev 86 84 * @rpdev: prepared rpdev to be used for creating endpoints