linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaud Pouliquen <arnaud.pouliquen@st.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<arnaud.pouliquen@st.com>
Subject: [PATCH 07/13] rpmsg: control: add driver registration API
Date: Fri, 31 Jul 2020 14:10:37 +0200	[thread overview]
Message-ID: <20200731121043.24199-8-arnaud.pouliquen@st.com> (raw)
In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com>

Add API for RPMsg driver to register the supported service.
This API has to be called during RPMsg driver init to declare the
service. Then the RPMsg control will be able to instantiate
associated device.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/rpmsg/rpmsg_ctrl.c     | 57 ++++++++++++++++++++++++++++++++++
 drivers/rpmsg/rpmsg_internal.h |  3 ++
 2 files changed, 60 insertions(+)

diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c
index d31b1ba51fa7..8773c8395401 100644
--- a/drivers/rpmsg/rpmsg_ctrl.c
+++ b/drivers/rpmsg/rpmsg_ctrl.c
@@ -26,6 +26,20 @@ struct rpmsg_ctrl_dev {
 	struct device dev;
 };
 
+/**
+ * struct rpmsg_ctl_info - control info list node
+ * @ctrl:	control driver info
+ * @node:	list node
+ *
+ * This structure is used by rpmsg_ctl to list the registered drivers services
+ */
+struct rpmsg_ctl_info {
+	const struct rpmsg_drv_ctrl_info *ctrl;
+	struct list_head node;
+};
+
+static LIST_HEAD(rpmsg_drv_list);
+
 static DEFINE_IDA(rpmsg_ctrl_ida);
 static DEFINE_IDA(rpmsg_minor_ida);
 
@@ -176,6 +190,49 @@ static struct rpmsg_driver rpmsg_ctrl_driver = {
 	},
 };
 
+/**
+ * rpmsg_ctrl_register_ctl() -register control for the associated service
+ * @ctrl: rpmsg driver information
+ *
+ * This function is called by the rpmsg driver to register a service that will
+ * be exposed to be instantiate by the application.
+ */
+int  rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl)
+{
+	struct rpmsg_ctl_info *drv_info;
+
+	drv_info =  kzalloc(sizeof(*drv_info), GFP_KERNEL);
+	if (!drv_info)
+		return -ENOMEM;
+
+	drv_info->ctrl = ctrl;
+
+	list_add_tail(&drv_info->node, &rpmsg_drv_list);
+
+	return 0;
+}
+EXPORT_SYMBOL(rpmsg_ctrl_register_ctl);
+
+/**
+ * rpmsg_ctrl_unregister_ctl() -unregister control for the associated service
+ * @ctrl: the rpmsg control information
+ *
+ * This function is called by the rpmsg driver to unregister the associated
+ * service.
+ */
+void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl)
+{
+	struct rpmsg_ctl_info *drv_info, *tmp;
+
+	list_for_each_entry_safe(drv_info, tmp, &rpmsg_drv_list, node) {
+		if (drv_info->ctrl == ctrl) {
+			list_del(&drv_info->node);
+			kfree(drv_info);
+		}
+	}
+}
+EXPORT_SYMBOL(rpmsg_ctrl_unregister_ctl);
+
 static int rpmsg_ctrl_init(void)
 {
 	int ret;
diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h
index 811d6e27a720..2f22ad45cb18 100644
--- a/drivers/rpmsg/rpmsg_internal.h
+++ b/drivers/rpmsg/rpmsg_internal.h
@@ -137,4 +137,7 @@ static inline int rpmsg_ctl_register_device(struct rpmsg_device *rpdev)
 int rpmsg_ns_announce_create(struct rpmsg_device *rpdev);
 int rpmsg_ns_announce_destroy(struct rpmsg_device *rpdev);
 
+int  rpmsg_ctrl_register_ctl(const struct rpmsg_drv_ctrl_info *ctrl);
+void rpmsg_ctrl_unregister_ctl(const struct rpmsg_drv_ctrl_info *ctrl);
+
 #endif
-- 
2.17.1


  parent reply	other threads:[~2020-07-31 12:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 12:10 [PATCH 00/13] introduce IOCTL interface for RPMsg channel management Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 01/13] rpmsg: introduce rpmsg raw driver Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 02/13] rpmsg: introduce rpmsg_control driver for channel creation Arnaud Pouliquen
2020-07-31 15:56   ` Randy Dunlap
2020-07-31 12:10 ` [PATCH 03/13] rpmsg: add helper to create the rpmsg ctrl device Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 04/13] rpmsg: virtio: probe the rpmsg_ctrl device Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 05/13] rpmsg: uapi: add service param for create destroy ioctls Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 06/13] rpmsg: add RPMsg control info structure Arnaud Pouliquen
2020-07-31 12:10 ` Arnaud Pouliquen [this message]
2020-07-31 12:10 ` [PATCH 08/13] rpmsg: raw: register service to the rpmsg control Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 09/13] rpmsg: add override field in channel info Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 10/13] rpmsg: ns: initialize channel info override field Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 11/13] rpmsg: virtio: use the driver_override in channel creation Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 12/13] rpmsg: control: implement the ioctrl function to create device Arnaud Pouliquen
2020-07-31 12:10 ` [PATCH 13/13] rpmsg: ctrl: add support of the endpoints release 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=20200731121043.24199-8-arnaud.pouliquen@st.com \
    --to=arnaud.pouliquen@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=mathieu.poirier@linaro.org \
    --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;
as well as URLs for NNTP newsgroup(s).