Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp657430pxb; Thu, 21 Jan 2021 17:03:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxFWaGdCTiHiQI8rWZvuvy4S4OFPv4Ldv/zTnt+bf9gvwFrvuqmj1Zs5FcWpBL4nP5rUHS X-Received: by 2002:a17:906:7e49:: with SMTP id z9mr1343171ejr.447.1611277390393; Thu, 21 Jan 2021 17:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611277390; cv=none; d=google.com; s=arc-20160816; b=g5iwKnILiaBdHcakukI9xhKjO1vZGIDKjpI46rgk//JpFVFBDg7nNwH7907emVTZXS DReT1s2es4AktjmmDn66+82ButG/R09kOUCSb13G7izAGZqkD33w80nPNvkkq0EbozXI krQ1FYTHlUTAMSlX/vmaF+ZHyeGra9szlkxdiOTmMZeZS6qfAX/fV+nH2bx8ZU6z0FQ9 Q78/S2zvD9uCojwL5fReK86emYHGsOxcT28vfysQUiVBRBc+Ah1R+Qq0iDXibsdfLrvk FYwjkh8mqcVgPH7JDL/z7zL4p4V8Uj0LnHkHVOvhBpEYD2rbAz3ml/1qrpmhJhD7WQ9R LQNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oJrGhqFdkfW9wRZyay7gwNcE73cpE4zERtrcMcbTWr0=; b=Vw15mMW3HBFCySd0UjTWiPrSkWO3+hBOAfGcL3H+9ltm8ZtIhm/fEZQdWtGLBc6ndG hypeU9Xx+kaq57z1A9eHbBB8VqnGcLV/Qd3XKkLkEJJzBiiY5aJo/O3stpQmzv3aLR1c ED0UIK/nJPNsZMAFKAuf4ILC9gjW72lraRMH41o6AI9rlBYXo8GnEyqSC2mJXOhN/BYn 8wX6H3bFnuY4LmPQONccQFaZjW8nF2XtF9Nwt7BYieZ3F2kyJ6Jg2itzCTJf5OH1hbh7 o7jGu/pDxKiga/vjMJ5OquyLAtTdNOIEExAki0tBodoSvWyT6Kskwh8yCMF6YLd6n1Gl SsEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OPELpH75; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 17si2478714ejt.596.2021.01.21.17.02.46; Thu, 21 Jan 2021 17:03:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OPELpH75; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726277AbhAUXx4 (ORCPT + 99 others); Thu, 21 Jan 2021 18:53:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbhAUXxx (ORCPT ); Thu, 21 Jan 2021 18:53:53 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 491F9C0613ED for ; Thu, 21 Jan 2021 15:53:01 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id u11so2188758plg.13 for ; Thu, 21 Jan 2021 15:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=oJrGhqFdkfW9wRZyay7gwNcE73cpE4zERtrcMcbTWr0=; b=OPELpH75YfQI1ATMiUGuilGIUBPs8DsfCGvxdD/RxoAW+K4McjtBdgnhXdrGn/sFIi FFFHaobn9FbUP/3jpSBU7Fl48nrsSETVJaAgZhzmJQKea0q2Tp6Q1S3iREur5mT8Fndj ToIWyQPv+mVhJ9RNEMO17mrBpmavV39aPqP9VcmYkLbjxLLgB2fpALfHSVVLh2+NnGtp 79qKIAvIN9KaZlHViSxHuZjpU8ONYfEyGA5Vd8U0YSDWUpboZ+vQ1o7s9FgyJorqqn7m vzFHOo40C6i18UnWn60qehhiBeY9fckRMbffVdWOyea5kZlP/q6124YSsJ4Oah15AoFc GOpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oJrGhqFdkfW9wRZyay7gwNcE73cpE4zERtrcMcbTWr0=; b=MEoUFaQu2w7cjVPFqTNDxEuTb1s1OYVF7YA9yYkCWFfqwctGGnc/hAAoe6c9nBxOZl qg8P08Wct4oustgNSw0+T4yRhYtdNOWCBKGUmUsOGSuHUc/yjUND6mRhfraVw+8ExfR8 aS8fJRuQU4JATm2zziuCgA720HLd3JcBDKCE6ZCk92/4mm80S24ZJhtgPzrmZksxWW5R zvoradGZWWrLYmx4RCJ5K96OtsfLgRkTSgijJ5gxe6vHxcJa1X3xPYM44vAMOuwk1ElQ utFT0tFsiPnJwy//yqT0PuZ54w9jG2/tXVd7YoafTsIa5/IqZ4I5W/jadxWFwNr39jo1 fwDQ== X-Gm-Message-State: AOAM531hkaZIEnrbaUXb5Uf/9mcmJHG5ukuUXXybKhtmjx85kuTGnidB Hk2/PPP+HHnvV5if4WkLOBA+xw== X-Received: by 2002:a17:902:834a:b029:de:343e:adb0 with SMTP id z10-20020a170902834ab02900de343eadb0mr1943726pln.28.1611273180836; Thu, 21 Jan 2021 15:53:00 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id n128sm6948132pga.55.2021.01.21.15.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 15:53:00 -0800 (PST) Date: Thu, 21 Jan 2021 16:52:58 -0700 From: Mathieu Poirier To: Arnaud Pouliquen Cc: Bjorn Andersson , Ohad Ben-Cohen , Andy Gross , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v2 04/16] rpmsg: ctrl: implement the ioctl function to create device Message-ID: <20210121235258.GG611676@xps15> References: <20201222105726.16906-1-arnaud.pouliquen@foss.st.com> <20201222105726.16906-5-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201222105726.16906-5-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 22, 2020 at 11:57:14AM +0100, Arnaud Pouliquen wrote: > Implement the ioctl function that parses the list of > rpmsg drivers registered to create an associated device. > To be ISO user API, in a first step, the driver_override > is only allowed for the RPMsg raw service, supported by the > rpmsg_char driver. > > Signed-off-by: Arnaud Pouliquen > --- > drivers/rpmsg/rpmsg_ctrl.c | 43 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 41 insertions(+), 2 deletions(-) > > diff --git a/drivers/rpmsg/rpmsg_ctrl.c b/drivers/rpmsg/rpmsg_ctrl.c > index 065e2e304019..8381b5b2b794 100644 > --- a/drivers/rpmsg/rpmsg_ctrl.c > +++ b/drivers/rpmsg/rpmsg_ctrl.c > @@ -56,12 +56,51 @@ 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; > + } > + I'm unsure about the above... To me this looks like what the .match() function of a bus would do. And when I read Bjorn's comment he brought up the auxiliary_bus. I don't know about the auxiliary_bus but it is worth looking into. Registering with a bus would streamline a lot of the code in this patchset. I'm out of time for today - I will continue tomorrow. Thanks, Mathieu > + 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; > + > + /* > + * In a frst step only the rpmsg_raw service is supported. > + * The override is foorced to RPMSG_RAW_SERVICE > + */ > + chinfo.driver_override = rpmsg_ctrl_get_drv_name(RPMSG_RAW_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 >