This function registers a rpmsg_ctl device and its associated /dev/rpmsg_ctrl interface.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliq...@foss.st.com> --- drivers/rpmsg/rpmsg_ctrl.c | 16 ++++++++++++++++ include/linux/rpmsg.h | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c index 8381b5b2b794..e4b0ca6dffe3 100644 --- a/drivers/rpmsg/rpmsg_ctrl.c +++ b/drivers/rpmsg/rpmsg_ctrl.c @@ -271,6 +271,22 @@ void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl) } EXPORT_SYMBOL(rpmsg_ctrl_unregister_ctl); +/** + * rpmsg_ctl_register_device() - register control device based on rpdev + * @rpdev: prepared rpdev to be used for creating endpoints + * + * This function wraps rpmsg_register_device() preparing the rpdev for use as + * a control rpmsg driver forcing the channel name. + */ +int rpmsg_ctl_register_device(struct rpmsg_device *rpdev) +{ + strcpy(rpdev->id.name, KBUILD_MODNAME); + rpdev->driver_override = KBUILD_MODNAME; + + return rpmsg_register_device(rpdev); +} +EXPORT_SYMBOL(rpmsg_ctl_register_device); + static int rpmsg_ctrl_init(void) { int ret; diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 5681c585e235..86540528325f 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -335,6 +335,8 @@ static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept, int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl); void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl); +int rpmsg_ctl_register_device(struct rpmsg_device *rpdev); + #else static inline int rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl) @@ -346,6 +348,11 @@ static inline void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *c { } +static inline int rpmsg_ctl_register_device(struct rpmsg_device *rpdev) +{ + return 0; +} + #endif /* IS_ENABLED(CONFIG_RPMSG_CTRL) */ #endif /* _LINUX_RPMSG_H */ -- 2.17.1