Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1480845pxb; Thu, 4 Mar 2021 12:26:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhNcm17Gpxls2UxNQanh5I5WozaaQS8sEEtPsdv3kRhK/oCzU342XpbKmC7nvZLOOO7ur9 X-Received: by 2002:a17:906:d938:: with SMTP id rn24mr6554555ejb.87.1614889593160; Thu, 04 Mar 2021 12:26:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614889593; cv=none; d=google.com; s=arc-20160816; b=tUg5E1LA8zRxVMR/ydOleADooyqMrb2rf2zrs2kQf64QhVe/KPHynXiFZXah4h5UWg Ns7QQsInNxdLx3giWPafGpwKVT2bWzWS9ZoNAv/hYsXL1dL9qvgy58Z/EKbMqqJx07hb QfFgicvKuJmytsYL6CTzgTNgR+W/2FK8FcuMSSsTXmd341v57F4e/MhgVEaZmVqxJY9t EzcOs/sFRoHTJ/pDTlcqRqi9Go+TgS1l28Y4fbcvbXWlaIN1iyAWuUJ7n3NHB+moDaVy VMf6wYFQkjjeSe6VED55dKEuJAEoaNGGqzfqLKc3oUk2QISfGWgvBTT3FL20o0c90oxo 5pTg== 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=XZv1luet9j7TnZYm7Gox6kRSD9fWpPc1LUY0U6nOa5s=; b=aLVerm6uPvV8uAX4YYdnx2ct4DL+XAXt3Bt6mW2dbGtFWg+YMJ76YQE+BitfWsFNZ2 KZj6hL9PA3VGx3x+v3rpx841njWAUzHjVdQAcgoGrSZL0m9+jDfJazaMuwcvdHf+p33W QVEpcOkNBvMY5bk7svvWrDiAqozJOxBgfiUeY7/KNY9w2QDrOau44rRbnhChZVxUJ3MG V7HfFBWdyG6xsNIPd2nRxUr6D/Ro9Q49WPRqw2kaFXYGAuchWsrw13mtbovdNozfz1L5 qiL6EvMv1xEmP2FSnxFtuM8Lpdd6HQZ7XIyIbBeisWkG/FkYjzRZ0qLRbrPn94VrKFLY +QKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y+h9s4sn; 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 a20si113494ejg.257.2021.03.04.12.26.10; Thu, 04 Mar 2021 12:26:33 -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=Y+h9s4sn; 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 S1376703AbhCBVAI (ORCPT + 99 others); Tue, 2 Mar 2021 16:00:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347485AbhCBSHF (ORCPT ); Tue, 2 Mar 2021 13:07:05 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B4ACC061223 for ; Tue, 2 Mar 2021 09:57:05 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id c19so2436001pjq.3 for ; Tue, 02 Mar 2021 09:57:05 -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=XZv1luet9j7TnZYm7Gox6kRSD9fWpPc1LUY0U6nOa5s=; b=Y+h9s4snrD/QHKXvqv+wG3eyoISyFrn0nHCU03dBFCu4kWrSxrqR+GKZ5JfysTORMG MH8rvIDadTd/v5GVH1qTkG4L6F+NL6UXnSe0HkQhGGIlf+OzX9FUUKpZ4u583YvETHZi DhYOTLffSolLB90COxzoR36lseOVvxRRXC7Y5X07q7tOrIorLcxOK9lmGNfsU4cvpgi8 gSd+/C9V1atQernhfZgMrtKUAEJY5IUnFbolqEoyo6Yuh4BC77TEdptTze/jyLB4oqbe Tj+J7zuo1PHekHvyxyUD9SVE6bOyVjrEGqCt/XbbSMbHqDCyrex4VFcZ2wQJ+MWlXWNQ meLA== 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=XZv1luet9j7TnZYm7Gox6kRSD9fWpPc1LUY0U6nOa5s=; b=r107/KQrRqrwbLvB3y92MDjQTQ9snz8ut5yFHDlNqFtymfonmGiGzOysx5X8vkjDOD ni31YInqtcI8T6f2bkgqf/ROt+/yKbOwTFzXXkdTHOoD8TgLUi0m1+lvD1bn5gLvvKa1 vAG+k7BNejes7402liiPy+MIKOJOI6kOqQHcjrDEnNzfeKJVYCN+qBsoqquukZ6jfKLy K4t/R7q04W4ZYJqDdSIfrjd3hoQoTiU8TzUPtfzJ7bUh4mqBnrVgMs6AtbRB43AOk2fU 0xuc/nzzwSnhHUHCMyrzMkH6IDqsTEYNnEwR3/I0o4BifSdMWI4zH0PCzxKrE72Vt3Os gOxw== X-Gm-Message-State: AOAM530fR6X04sY91JOU+Z46l4lrYamshMcDkjtZM+cFLcZPJOq7tK7B jwhcBWPC5aN9Y20niCFzpjPXyFXujQVT1Q== X-Received: by 2002:a17:902:ff0d:b029:e4:a497:fdad with SMTP id f13-20020a170902ff0db02900e4a497fdadmr12476777plj.33.1614707824846; Tue, 02 Mar 2021 09:57:04 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id u2sm3277561pjy.14.2021.03.02.09.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 09:57:04 -0800 (PST) Date: Tue, 2 Mar 2021 10:57:02 -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 v5 04/16] rpmsg: char: export eptdev create an destroy functions Message-ID: <20210302175702.GA3791957@xps15> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> <20210219111501.14261-5-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210219111501.14261-5-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Good morning, I have started to review this set - comments will be staggered over several days. On Fri, Feb 19, 2021 at 12:14:49PM +0100, Arnaud Pouliquen wrote: > To prepare the split code related to the control and the endpoint > devices in separate files: > - suppress the dependency with the rpmsg_ctrldev struct, > - rename and export the functions in rpmsg_char.h. > > Suggested-by: Mathieu Poirier > Signed-off-by: Arnaud Pouliquen > --- > drivers/rpmsg/rpmsg_char.c | 22 ++++++++++------ > drivers/rpmsg/rpmsg_char.h | 51 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 66 insertions(+), 7 deletions(-) > create mode 100644 drivers/rpmsg/rpmsg_char.h > > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c > index 9e33b53bbf56..78a6d19fdf82 100644 > --- a/drivers/rpmsg/rpmsg_char.c > +++ b/drivers/rpmsg/rpmsg_char.c > @@ -1,5 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0 > /* > + * Copyright (C) 2021, STMicroelectronics > * Copyright (c) 2016, Linaro Ltd. > * Copyright (c) 2012, Michal Simek > * Copyright (c) 2012, PetaLogix > @@ -22,6 +23,7 @@ > #include > #include > > +#include "rpmsg_char.h" > #include "rpmsg_internal.h" > > #define RPMSG_DEV_MAX (MINORMASK + 1) > @@ -78,7 +80,7 @@ struct rpmsg_eptdev { > wait_queue_head_t readq; > }; > > -static int rpmsg_eptdev_destroy(struct device *dev, void *data) > +static int rpmsg_eptdev_destroy(struct device *dev) > { > struct rpmsg_eptdev *eptdev = dev_to_eptdev(dev); > > @@ -277,7 +279,7 @@ static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd, > if (cmd != RPMSG_DESTROY_EPT_IOCTL) > return -EINVAL; > > - return rpmsg_eptdev_destroy(&eptdev->dev, NULL); > + return rpmsg_eptdev_destroy(&eptdev->dev); > } > > static const struct file_operations rpmsg_eptdev_fops = { > @@ -336,10 +338,15 @@ static void rpmsg_eptdev_release_device(struct device *dev) > kfree(eptdev); > } > > -static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, > +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) > +{ > + return rpmsg_eptdev_destroy(dev); > +} > +EXPORT_SYMBOL(rpmsg_chrdev_eptdev_destroy); Below we have rpmsg_chrdev_create_eptdev() so it would make sense to have rpmsg_chrdev_destroy_ept(). I would also rename rpmsg_eptdev_destroy() to rpmsg_chrdev_destroy_ept() and export that symbol rather than introducing a function that only calls another one. You did exactly that for rpmsg_chrdev_create_eptdev(). > + > +int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent, > struct rpmsg_channel_info chinfo) > { > - struct rpmsg_device *rpdev = ctrldev->rpdev; > struct rpmsg_eptdev *eptdev; > struct device *dev; > int ret; > @@ -359,7 +366,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, > > device_initialize(dev); > dev->class = rpmsg_class; > - dev->parent = &ctrldev->dev; > + dev->parent = parent; > dev->groups = rpmsg_eptdev_groups; > dev_set_drvdata(dev, eptdev); > > @@ -402,6 +409,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, > > return ret; > } > +EXPORT_SYMBOL(rpmsg_chrdev_create_eptdev); > > static int rpmsg_ctrldev_open(struct inode *inode, struct file *filp) > { > @@ -441,7 +449,7 @@ static long rpmsg_ctrldev_ioctl(struct file *fp, unsigned int cmd, > chinfo.src = eptinfo.src; > chinfo.dst = eptinfo.dst; > > - return rpmsg_eptdev_create(ctrldev, chinfo); > + return rpmsg_chrdev_create_eptdev(ctrldev->rpdev, &ctrldev->dev, chinfo); Not sure why we have to change the signature of rpmsg_eptdev_create() but I may find an answer to that question later on in the patchset. > }; > > static const struct file_operations rpmsg_ctrldev_fops = { > @@ -527,7 +535,7 @@ static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev) > int ret; > > /* Destroy all endpoints */ > - ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_eptdev_destroy); > + ret = device_for_each_child(&ctrldev->dev, NULL, rpmsg_chrdev_eptdev_destroy); > if (ret) > dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret); > > diff --git a/drivers/rpmsg/rpmsg_char.h b/drivers/rpmsg/rpmsg_char.h > new file mode 100644 > index 000000000000..0feb3ea9445c > --- /dev/null > +++ b/drivers/rpmsg/rpmsg_char.h > @@ -0,0 +1,51 @@ > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > +/* > + * Copyright (C) STMicroelectronics 2021. > + */ > + > +#ifndef __RPMSG_CHRDEV_H__ > +#define __RPMSG_CHRDEV_H__ > + > +#if IS_ENABLED(CONFIG_RPMSG_CHAR) > +/** > + * rpmsg_chrdev_create_eptdev() - register char device based on an endpoint > + * @rpdev: prepared rpdev to be used for creating endpoints > + * @parent: parent device > + * @chinfo: assiated endpoint channel information. > + * > + * This function create a new rpmsg char endpoint device to instantiate a new > + * endpoint based on chinfo information. > + */ > +int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, struct device *parent, > + struct rpmsg_channel_info chinfo); > + > +/** > + * rpmsg_chrdev_eptdev_destroy() - destroy created char device > + * @data: parent device > + * @chinfo: assiated endpoint channel information. > + * > + * This function create a new rpmsg char endpoint device to instantiate a new > + * endpoint based on chinfo information. > + */ > +int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data); > + > +#else /*IS_ENABLED(CONFIG_RPMSG_CHAR) */ > + > +static inline int rpmsg_chrdev_create_eptdev(struct rpmsg_device *rpdev, > + struct device *parent, > + struct rpmsg_channel_info chinfo) > +{ > + return -EINVAL; > +} > + > +static inline int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data) > +{ > + /* This shouldn't be possible */ > + WARN_ON(1); > + > + return 0; > +} > + > +#endif /*IS_ENABLED(CONFIG_RPMSG_CHAR) */ > + > +#endif /*__RPMSG_CHRDEV_H__ */ > -- > 2.17.1 >