On 10/9/21 1:29 AM, Bjorn Andersson wrote: > On Mon 12 Jul 05:37 PDT 2021, Arnaud Pouliquen wrote: > [..] >> diff --git a/drivers/rpmsg/rpmsg_char.h b/drivers/rpmsg/rpmsg_char.h >> new file mode 100644 >> index 000000000000..22573b60e008 >> --- /dev/null >> +++ b/drivers/rpmsg/rpmsg_char.h >> @@ -0,0 +1,49 @@ >> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ >> +/* >> + * Copyright (C) STMicroelectronics 2021. >> + */ >> + >> +#ifndef __RPMSG_CHRDEV_H__ >> +#define __RPMSG_CHRDEV_H__ >> + >> +#if IS_REACHABLE(CONFIG_RPMSG_CHAR) > > This does allow you to build a kernel with RPMSG_CHAR=m and RPMSG_CTRL=y > without link failures. Any modules in the system will be able to call > rpmsg_chrdev_eptdev_create(), but the rpmsg_ctrl driver will only end up > in the stub. > > This sounds like a recipe for a terrible debugging session... The RPMSG_CREATE_EPT_IOCTL control create a dependency between the rpmsg_ctrl and the rpmsg_char. The build error option seems not a good alternative. And in case of RPMSG_CHAR=m and RPMSG_CTRL=y, an error is returned so not only a stub. What about adding a WARN_ON(1) in rpmsg_chrdev_eptdev_create with an associated comment to ease the debug? Regards, Arnaud > > Regards, > Bjorn > >> +/** >> + * rpmsg_chrdev_eptdev_create() - register char device based on an endpoint >> + * @rpdev: prepared rpdev to be used for creating endpoints >> + * @parent: parent device >> + * @chinfo: associated endpoint channel information. >> + * >> + * This function create a new rpmsg char endpoint device to instantiate a new >> + * endpoint based on chinfo information. >> + */ >> +int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, >> + struct rpmsg_channel_info chinfo); >> + >> +/** >> + * rpmsg_chrdev_eptdev_destroy() - destroy created char device endpoint. >> + * @data: private data associated to the endpoint device >> + * >> + * This function destroys a rpmsg char endpoint device created by the RPMSG_DESTROY_EPT_IOCTL >> + * control. >> + */ >> +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data); >> + >> +#else /*IS_REACHABLE(CONFIG_RPMSG_CHAR) */ >> + >> +static inline int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, >> + struct rpmsg_channel_info chinfo) >> +{ >> + return -EINVAL; >> +} >> + >> +static inline int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) >> +{ >> + /* This shouldn't be possible */ >> + WARN_ON(1); >> + >> + return 0; >> +} >> + >> +#endif /*IS_REACHABLE(CONFIG_RPMSG_CHAR) */ >> + >> +#endif /*__RPMSG_CHRDEV_H__ */ >> -- >> 2.17.1 >>