Linux-remoteproc Archive on lore.kernel.org
 help / color / 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 12/13] rpmsg: control: implement the ioctrl function to create device
Date: Fri, 31 Jul 2020 14:10:42 +0200
Message-ID: <20200731121043.24199-13-arnaud.pouliquen@st.com> (raw)
In-Reply-To: <20200731121043.24199-1-arnaud.pouliquen@st.com>

Implement the ioctrl function that parses the list of
rpmsg drivers registered to create an associated device.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/rpmsg/rpmsg_ctrl.c | 39 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c
index 8773c8395401..d2a6dbb8798f 100644
--- a/drivers/rpmsg/rpmsg_ctrl.c
+++ b/drivers/rpmsg/rpmsg_ctrl.c
@@ -55,12 +55,47 @@ static int rpmsg_ctrl_dev_open(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+static const char *rpmsg_ctrl_get_drv_name(u32 service)
+{
+	struct rpmsg_ctl_info *drv_info;
+
+	list_for_each_entry(drv_info, &rpmsg_drv_list, node) {
+		if (drv_info->ctrl->service == service)
+			return drv_info->ctrl->drv_name;
+	}
+
+	return NULL;
+}
+
 static long rpmsg_ctrl_dev_ioctl(struct file *fp, unsigned int cmd,
 				 unsigned long arg)
 {
 	struct rpmsg_ctrl_dev *ctrldev = fp->private_data;
-
-	dev_info(&ctrldev->dev, "Control not yet implemented\n");
+	void __user *argp = (void __user *)arg;
+	struct rpmsg_channel_info chinfo;
+	struct rpmsg_endpoint_info eptinfo;
+	struct rpmsg_device *newch;
+
+	if (cmd != RPMSG_CREATE_EPT_IOCTL)
+		return -EINVAL;
+
+	if (copy_from_user(&eptinfo, argp, sizeof(eptinfo)))
+		return -EFAULT;
+
+	chinfo.driver_override = rpmsg_ctrl_get_drv_name(eptinfo.service);
+	if (!chinfo.driver_override)
+		return -ENODEV;
+
+	memcpy(chinfo.name, eptinfo.name, RPMSG_NAME_SIZE);
+	chinfo.name[RPMSG_NAME_SIZE - 1] = '\0';
+	chinfo.src = eptinfo.src;
+	chinfo.dst = eptinfo.dst;
+
+	newch = rpmsg_create_channel(ctrldev->rpdev, &chinfo);
+	if (!newch) {
+		dev_err(&ctrldev->dev, "rpmsg_create_channel failed\n");
+		return -ENXIO;
+	}
 
 	return 0;
 };
-- 
2.17.1


  parent reply index

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 ` [PATCH 07/13] rpmsg: control: add driver registration API Arnaud Pouliquen
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 ` Arnaud Pouliquen [this message]
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-13-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

Linux-remoteproc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-remoteproc/0 linux-remoteproc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-remoteproc linux-remoteproc/ https://lore.kernel.org/linux-remoteproc \
		linux-remoteproc@vger.kernel.org
	public-inbox-index linux-remoteproc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-remoteproc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git