Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp652586pxy; Wed, 5 May 2021 10:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz21l4hWAZZl2PWhtfVJLajKKIu0s/rDp2708yu+IOcfB9eLWgx7XGV7f2r6yRtqRGz7juZ X-Received: by 2002:a17:902:6bc7:b029:ee:f84f:1093 with SMTP id m7-20020a1709026bc7b02900eef84f1093mr102053plt.37.1620235369154; Wed, 05 May 2021 10:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620235369; cv=none; d=google.com; s=arc-20160816; b=crqftK54qSmU2vD9Zc+jsUpQIzFPuPOzM5R0EmicWtL9hlagUsocHwsasfWteKhWRR hWJlShZVLgFCruo3Tgibz2MBcr7bnpdaNpfHDB0hW2gVmLG3OqRH/M6mfVwXCVM18HIh qf3ydxOuecqF0H7bEzjUlj3rIe9mCS1J+8g+dd7p3HCK+7PAXqdtv9S7Tmp/u3njzvlL lkm1hcg1YDwkoT41896pKqqV3/lCclWeSPEI5Nu8UJUL+wrHFXI3ejUzVnhHHdC7Ij// MWQ27py05BY1pz84LpGLVFHGUlfHcw5eSiNxoAnvYnYdJYw9XYdv8f6SVb5rcAW0efXg e6gA== 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=DoaVFzcWT65RDKIsoX6i4zeOSXhY9rWNOtYUEZapV9M=; b=iTWN65GnWHInJWnbQ/+xVzhnckee9vS/USGfl+z+iUYmprmB/WHIM6B8+Wy9qHKzMj XKIZSsY7SJj/kaXo1ngZlJXJZxdW1f7qWJ2e2NXdbQGoue4nAzUsLiy7Z0JUGdUylOWK C7J7VrX1uItBkaO8+GrcCjZhHAzmdrAjdw2Wi+JXCVxjdaP8hWezyRwGUV+7mDJyh+Jv TdFtVskPMrAs8T1xiP75YxYCCv4L5CKXbVHRk1t65K/NIGEMXOlBj54GRrDiBC1OgOMX aCvDTCiuhCE/0RtK8Uqm6SGjNR7PbafdoebXWWma+xUFXcyFihzGHvMa84TTW9k6DqO4 hI3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mbZtkkRl; 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 y5si21501750pfy.195.2021.05.05.10.22.35; Wed, 05 May 2021 10:22:49 -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=mbZtkkRl; 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 S240836AbhEERWB (ORCPT + 99 others); Wed, 5 May 2021 13:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235761AbhEERH1 (ORCPT ); Wed, 5 May 2021 13:07:27 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F4000C03461E for ; Wed, 5 May 2021 09:42:02 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id s22so2180311pgk.6 for ; Wed, 05 May 2021 09:42:02 -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=DoaVFzcWT65RDKIsoX6i4zeOSXhY9rWNOtYUEZapV9M=; b=mbZtkkRloDaT6rF9tDRW/WZymf+9jLo9twlvhFYxhRfFiYZWjAvMyvN+viRiqjgKqt UyNF1Iyh1k99tg8rgQ6BV9Ounqvoxr+rsdEzMRXR1g485Q9YLIoIHHPIXsXrBKG2ZiUD nB4R4irRIQryWE92wgzcDCfKhD347u2q3t4um5tDOwylV4/JpVT4quKNpXWYBJD+R1XZ 5mj3Q2S4ucykX2zQpNuWEZmj6Uy9OWc010d33E+j2WUygzeT0YPt7CZAScPpA/igYKG1 LCTLsArcXQyVbFFbWENRBoQWIb3qt8GrYR870JQZMymqQ4A/rADuCXEcgXn+I5XPqGD/ vzmQ== 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=DoaVFzcWT65RDKIsoX6i4zeOSXhY9rWNOtYUEZapV9M=; b=kVTaEbHFJ9LkiT86zT5oUtWGmMVlfOWQt3uFbetp295ZpfpirCcCP2shDFx+IClZRR DPzZFYyIIsHvuB4bRRIM42nIPWsueveUVH/9afYFg0WJqW2C+MrMaC3ILPxMBtvOL77h 2SdqwcPv9uk3JzU/k5+KEPFgIZQcdxmhjccKr7sk0b/jXXopkcsPMJ0/SVHck94jA2Uu 0RvTHPbAzUjz/MXFF+W1XPoS5n2uJNJvFQwF0qOMHxZCruVSvjnK7nURxHFlsxrX8Az0 c7TBQVq1jHFTKOdU1E0aQdsLIKWfSN9g0tSGiDWycN+EyOXmicrUWGC6HFZ09rl4Rue2 3m0w== X-Gm-Message-State: AOAM533mMaqUZp5YANYE1H5eswOVJxrgTSHKSRwYkEmcqEUsMsgTCLTw zf9uwT1R0Q4zaPsj7dVGxN4z9w== X-Received: by 2002:a63:5322:: with SMTP id h34mr29849146pgb.182.1620232922466; Wed, 05 May 2021 09:42:02 -0700 (PDT) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id a18sm7502227pgg.51.2021.05.05.09.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 09:42:01 -0700 (PDT) Date: Wed, 5 May 2021 10:41:59 -0600 From: Mathieu Poirier To: Arnaud Pouliquen Cc: Bjorn Andersson , Ohad Ben-Cohen , 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 Message-ID: <20210505164159.GB1766375@xps15> References: <20210429135507.8264-1-arnaud.pouliquen@foss.st.com> <20210429135507.8264-6-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429135507.8264-6-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > 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 >