From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
Ohad Ben-Cohen <ohad@wizery.com>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v3 5/6] rpmsg: char: Introduce a rpmsg driver for the rpmsg char device
Date: Wed, 5 May 2021 10:41:59 -0600 [thread overview]
Message-ID: <20210505164159.GB1766375@xps15> (raw)
In-Reply-To: <20210429135507.8264-6-arnaud.pouliquen@foss.st.com>
Hi Arnaud,
On Thu, Apr 29, 2021 at 03:55:06PM +0200, Arnaud Pouliquen wrote:
> A rpmsg char device allows to probe the endpoint device on a remote name
> service announcement.
>
> With this patch the /dev/rpmsgX interface is created either by a user
> application or by the remote firmware.
>
> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
>
> ---
> update from V1:
>
> - add missing unregister_rpmsg_driver call on module exit.
> ---
> drivers/rpmsg/rpmsg_char.c | 53 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> index 5c6a7da6e4d7..9166454c1310 100644
> --- a/drivers/rpmsg/rpmsg_char.c
> +++ b/drivers/rpmsg/rpmsg_char.c
> @@ -18,6 +18,8 @@
>
> #include "rpmsg_char.h"
>
> +#define RPMSG_CHAR_DEVNAME "rpmsg-raw"
> +
> static dev_t rpmsg_major;
> static struct class *rpmsg_class;
>
> @@ -413,6 +415,40 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent
> }
> EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create);
>
> +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev)
> +{
> + struct rpmsg_channel_info chinfo;
> +
> + memcpy(chinfo.name, RPMSG_CHAR_DEVNAME, sizeof(RPMSG_CHAR_DEVNAME));
> + chinfo.src = rpdev->src;
> + chinfo.dst = rpdev->dst;
> +
> + return __rpmsg_chrdev_eptdev_create(rpdev, &rpdev->dev, chinfo, true);
> +}
> +
> +static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev)
> +{
> + int ret;
> +
> + ret = device_for_each_child(&rpdev->dev, NULL, rpmsg_chrdev_eptdev_destroy);
> + if (ret)
> + dev_warn(&rpdev->dev, "failed to destroy endpoints: %d\n", ret);
> +}
> +
> +static struct rpmsg_device_id rpmsg_chrdev_id_table[] = {
> + { .name = RPMSG_CHAR_DEVNAME },
> + { },
> +};
> +
> +static struct rpmsg_driver rpmsg_chrdev_driver = {
> + .probe = rpmsg_chrdev_probe,
> + .remove = rpmsg_chrdev_remove,
> + .id_table = rpmsg_chrdev_id_table,
> + .drv = {
> + .name = "rpmsg_chrdev",
> + },
> +};
The sole purpose of doing this is to create instances of rpmsg_chrdevs from the
name service - but is it really needed? Up to now and aside from GLINK and SMD,
there asn't been other users of it so I'm wondering if it is worth going through
all this trouble.
As such I suggest we don't go out of our way to expose rpmsg_chrdevs to the name
service. That way patches 4, 5 and 6 of this set can be dropped.
Thanks,
Mathieu
> +
> static int rpmsg_chrdev_init(void)
> {
> int ret;
> @@ -427,15 +463,30 @@ static int rpmsg_chrdev_init(void)
> if (IS_ERR(rpmsg_class)) {
> pr_err("failed to create rpmsg class\n");
> unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
> - return PTR_ERR(rpmsg_class);
> + ret = PTR_ERR(rpmsg_class);
> + goto free_region;
> + }
> +
> + ret = register_rpmsg_driver(&rpmsg_chrdev_driver);
> + if (ret < 0) {
> + pr_err("rpmsg: failed to register rpmsg raw driver\n");
> + goto free_class;
> }
>
> return 0;
> +
> +free_class:
> + class_destroy(rpmsg_class);
> +free_region:
> + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
> +
> + return ret;
> }
> postcore_initcall(rpmsg_chrdev_init);
>
> static void rpmsg_chrdev_exit(void)
> {
> + unregister_rpmsg_driver(&rpmsg_chrdev_driver);
> class_destroy(rpmsg_class);
> unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
> }
> --
> 2.17.1
>
next prev parent reply other threads:[~2021-05-05 17:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-29 13:55 [PATCH v3 0/6] Restructure the rpmsg char and introduce the rpmsg-raw channel Arnaud Pouliquen
2021-04-29 13:55 ` [PATCH v3 1/6] rpmsg: char: Export eptdev create an destroy functions Arnaud Pouliquen
2021-05-04 15:52 ` Mathieu Poirier
2021-04-29 13:55 ` [PATCH v3 2/6] rpmsg: Move the rpmsg control device from rpmsg_char to rpmsg_ctrl Arnaud Pouliquen
2021-05-04 16:09 ` Mathieu Poirier
2021-04-29 13:55 ` [PATCH v3 3/6] rpmsg: Update rpmsg_chrdev_register_device function Arnaud Pouliquen
2021-05-04 16:14 ` Mathieu Poirier
2021-04-29 13:55 ` [PATCH v3 4/6] rpmsg: char: Add possibility to create and reuse default endpoint Arnaud Pouliquen
2021-04-29 13:55 ` [PATCH v3 5/6] rpmsg: char: Introduce a rpmsg driver for the rpmsg char device Arnaud Pouliquen
2021-05-05 16:41 ` Mathieu Poirier [this message]
2021-05-05 18:25 ` Arnaud POULIQUEN
2021-05-06 16:11 ` Mathieu Poirier
2021-05-07 9:30 ` Arnaud POULIQUEN
2021-05-07 16:31 ` Mathieu Poirier
2021-05-17 10:04 ` Arnaud POULIQUEN
2021-05-17 15:47 ` Mathieu Poirier
2021-05-07 8:17 ` Julien Massot
2021-05-07 16:35 ` Mathieu Poirier
2021-04-29 13:55 ` [PATCH v3 6/6] rpmsg: char: Return error if user tries to destroy a default endpoint Arnaud Pouliquen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210505164159.GB1766375@xps15 \
--to=mathieu.poirier@linaro.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=bjorn.andersson@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=ohad@wizery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox