Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2382337pxb; Tue, 13 Apr 2021 00:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLz3RjXPdnsEpEgwuNYaqo8Bh26qVRtOScDlQk0+lxr5dJ0bTu7xqz6KOQK5Jjo/+xzTnI X-Received: by 2002:a17:90a:7e8b:: with SMTP id j11mr3323078pjl.11.1618297286123; Tue, 13 Apr 2021 00:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618297286; cv=none; d=google.com; s=arc-20160816; b=Zt9l0q8LTBCLDPnlLFSfwniulrqiBr34enz5y0jXJGQ1Kk64ONNPisQfXYO+s5E1b/ TOT5EZv99W0k6jLMpgonqB1kdSxyViGPGrTrwYteZZ1uLtxzyNgss5JluWZq6c8NGBrq PqhdAUof69IERQroCYdYXJDRLceeQX7+J3cEPtWg7LgfJSA202fX6IimpeAWy5yb/mNc r3yWauB11Tfx3vz4SAArWG+sxwm+R0qGUc8Pv+biQydnslJfSqQ41VjG8F+4C3aT2ar3 /SUqBA174A1caABzdAQhjEewbAPyBlRhU5NFk/hCxJKCMm7PGShElWxjBA4faEAZCVp9 MVNg== 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=lohhSZFnccGy8jGa7QsIGJ/XDmBANUFVxrmI+3Kxbmc=; b=MZ3J+Bs7mf/6M+mHv/6drUvM5LbzUFJZTNC8dNtwq3kXWjTGJnvqMjFLFqC312olG7 Gk5GNQ2d9p82GvDZ0kLeLu8tr0hbedElueUx81xT2EhrcYIWrzCNPxxnlQHFHZHGStOf baXNw/IK86NoZxLsVIdMdeHd69lM44E/DfCHh4kO1cb62orb011PRn0tmzlMgCYKaAr3 +VQyXHCvWSoAU8QWm43jQ9aNPyzomDWBw4LN8Jm6++pXoo4CqHEtwzfcIaTgWVxOBA70 q+3jEziXXypPhIzUIOezkidoo+mjq1fLB9+8I0cKIL/lHxOasNZUAzKSmffC5IlUIZha vg/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gLuCRPom; 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 j3si15938195pgf.453.2021.04.13.00.01.14; Tue, 13 Apr 2021 00:01:26 -0700 (PDT) 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=gLuCRPom; 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 S245361AbhDLTx4 (ORCPT + 99 others); Mon, 12 Apr 2021 15:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245360AbhDLTx4 (ORCPT ); Mon, 12 Apr 2021 15:53:56 -0400 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 5FF1AC061574 for ; Mon, 12 Apr 2021 12:53:36 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id 20so3003570pll.7 for ; Mon, 12 Apr 2021 12:53:36 -0700 (PDT) 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=lohhSZFnccGy8jGa7QsIGJ/XDmBANUFVxrmI+3Kxbmc=; b=gLuCRPomfgXVwaBM17qd3/jC44Igsbt8WKgl4XvpZ1GivlizY8xNMgmq3LpV0orNVf QRlsDYxDXcAWNh9LTSTY+k6DgWFzxnoS6/fI6e50qGwCnKlfPutiNGac7YsAKgaqDdcl GfPatf4ArWO3dzi4/u3Ky0dtmQPuAhnWSmcHwLW4Bt00QfaPpNkLdEhDIMOSaWhfnM9X AORpvC2Jme2Ge6RwjJFPEOP91o/siangMmSE1OlUWTMKcmsGQ3ls3xFvWCNn1O+3jTo1 MUsimmcWqSeG5aobnlTjYRqqidI8IYK+HpIhXHL4I6K8KJ4+HUWu0vQ1L+N6fmrnEMJw 43fw== 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=lohhSZFnccGy8jGa7QsIGJ/XDmBANUFVxrmI+3Kxbmc=; b=dNLctJRXTMXuh9Sn/g/LxJqcfAAuHAVz2ZCIeIqmtKbRLk+ZIDNxn3d2aqfoepP7Ue lAv4io+eQIfVtKyTWcNxBlKSwVObQ2TZSKOHecqYJa2RXMnG+ZNH0Bw4UNNmY7GFQs8x 3rCO6CT21oG1VJCmsJdhoMVBxgDv9RewMnLoJCCAd2jNpcdMcY5Cq7P84HnETvh2tEZ6 eIQwBUnibFyJRgaXtKUm8Jm3u+QaAADd17Et5Hokdz09V1PHruOeGK7ETUEgYWQX07Tk SaU5HMsy7svg/rTy5b8Jj/OX9KdR7gusbB7c6DD3Nt87N/tsDzL9RJaLRb0PdonSUHD7 teWw== X-Gm-Message-State: AOAM531uFKKXowixrE3kRR5HTm0QEPmJ5Gm6FoYVT1ztrsqeWSu+Lc7j rAIg+3zBcoTcAVhUHa6jWTeQYg== X-Received: by 2002:a17:90a:2807:: with SMTP id e7mr872172pjd.202.1618257215898; Mon, 12 Apr 2021 12:53:35 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id x30sm12391335pgl.39.2021.04.12.12.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 12:53:34 -0700 (PDT) Date: Mon, 12 Apr 2021 13:53:31 -0600 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 5/7] rpmsg: char: Introduce a rpmsg driver for the rpmsg char device Message-ID: <20210412195331.GA582352@xps15> References: <20210323122737.23035-1-arnaud.pouliquen@foss.st.com> <20210323122737.23035-6-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210323122737.23035-6-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 23, 2021 at 01:27:35PM +0100, 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 > --- > drivers/rpmsg/rpmsg_char.c | 58 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 57 insertions(+), 1 deletion(-) > > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c > index 7f6d46078179..69e774edb74b 100644 > --- a/drivers/rpmsg/rpmsg_char.c > +++ b/drivers/rpmsg/rpmsg_char.c > @@ -28,6 +28,8 @@ > > #define RPMSG_DEV_MAX (MINORMASK + 1) > > +#define RPMSG_CHAR_DEVNAME "rpmsg-raw" > + > static dev_t rpmsg_major; > > static DEFINE_IDA(rpmsg_ept_ida); > @@ -405,13 +407,67 @@ int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent > } > EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev); > > +static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) > +{ > + struct rpmsg_channel_info chinfo; > + struct rpmsg_eptdev *eptdev; > + > + if (!rpdev->ept) > + return -EINVAL; > + > + memcpy(chinfo.name, RPMSG_CHAR_DEVNAME, sizeof(RPMSG_CHAR_DEVNAME)); > + chinfo.src = rpdev->src; > + chinfo.dst = rpdev->dst; > + > + eptdev = __rpmsg_chrdev_create_eptdev(rpdev, &rpdev->dev, chinfo, NULL); > + if (IS_ERR(eptdev)) > + return PTR_ERR(eptdev); > + > + /* Set the private field of the default endpoint to retrieve context on callback. */ > + rpdev->ept->priv = eptdev; > + > + return 0; > +} > + > +static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) > +{ > + int ret; > + > + ret = device_for_each_child(&rpdev->dev, NULL, rpmsg_chrdev_destroy_eptdev); > + 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, > + .callback = rpmsg_ept_cb, > + .drv = { > + .name = "rpmsg_chrdev", > + }, > +}; > + > static int rpmsg_chrdev_init(void) > { > int ret; > > ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg"); > - if (ret < 0) > + if (ret < 0) { > pr_err("rpmsg: failed to allocate char dev region\n"); > + return ret; > + } > + > + ret = register_rpmsg_driver(&rpmsg_chrdev_driver); > + if (ret < 0) { > + pr_err("rpmsg: failed to register rpmsg raw driver\n"); > + unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); > + } Function unregister_rpmsg_driver() has to be called in rpmsg_chrdev_exit(). > > return ret; > } > -- > 2.17.1 >