Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp946578pxb; Thu, 4 Feb 2021 00:48:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPk8gkp+NOHy1mTbQ/rJjnRYrVTbu7g2bh1M65XOSgp9QkTwICaGoloRWmplIkcjvCuXLI X-Received: by 2002:a17:906:9401:: with SMTP id q1mr7182985ejx.516.1612428509852; Thu, 04 Feb 2021 00:48:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612428509; cv=none; d=google.com; s=arc-20160816; b=wPJnU3bi6y49Yxi3AJ3hRWQwUggtnApnKOrmLkx920r1wyrEKkUsP9OTtVknrSMFOE kmuwSSbnxXm3RrQApeNYSW1ULGtWcUx6A5puJBH2TcSt0W/GU/bZ2RUp1R5xRQUxSglA 9C9UamZlHlX9nnENZ0nlWcT015LQn57AsKF/VsXC0XtPBhNmFdHPz6LNPYjGXFWe/Sef 9UQCEYNXJUxRPxL70k5VrGkRFDJrykH8FE2l2NfsXHlDBPrPqaysWnzpQMvMQdjcitFB 35NDBSjei3/RV91EZ7yQ+1ib5HICq/yPOUhYMvDfKQeR9NAcZq6ej1lU+9Uusuz/Is/R 0hzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eL8fdw48NUXLNEyAuslWK3wA6wxsb+gv6VUFyukuFOo=; b=FVektmrSOd800k3u4Yx5dllI0og/RwaU/g225Z3DSfbIo+tKlZW3m1J2/o2MFTupbX dNwF1+UGLTo3mlkHw5aa7dPuEC28JNn2tZD7nFizqUvOt9Ua7zs9h4qHbwsXT/xCAXsr XCP8s+hJBmjOnbX+shnyd4Vop6+Cy68Wqx2lNf4P6dECtpMnbQW0dMZGetB2X9s2iY0O 6/lgoZ5YgEJ/AVkxFRHM0VKxZ7i9hWjZhMh6/AlMWZxSRqmgMsFy83QNe//JZxMqeKA9 NvGoPvehOroie5TQxb66TpBCHoWFOKHhg6cyMqdYgOFLTiZ0h5hP5bpFks6WAj0vRyVk +ypQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="bntdO/7j"; 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=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si3763055edf.469.2021.02.04.00.48.05; Thu, 04 Feb 2021 00:48:29 -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=@foss.st.com header.s=selector1 header.b="bntdO/7j"; 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=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235098AbhBDIq7 (ORCPT + 99 others); Thu, 4 Feb 2021 03:46:59 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:36058 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234727AbhBDIqu (ORCPT ); Thu, 4 Feb 2021 03:46:50 -0500 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1148gZBB023674; Thu, 4 Feb 2021 09:46:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=eL8fdw48NUXLNEyAuslWK3wA6wxsb+gv6VUFyukuFOo=; b=bntdO/7j+m8KlpUjcc0V2khV9EjN3MlNedJjUne25ZumGJ0GSisZROxnoUjMP+al4fZj uAh0XaUKq5roOc/DIf4zKHrhzW7tVjJk/yBLgQmw7HVmop7/mO90oT+bl+ZLK+4lF25F lOSHrJCgvHKnttvljT4RUv261+rJJwFT9kj2Kbl8OQ3domXuaXa779e6AwpuiaS2Oqwi IZWEmdoCnV8tY/DIHNyXc6uArkED0pEHqYsXsgIrJXNg60g5lUY71NtSPyu8q9KhNMn/ WLf8ndxKIA8KqHZI9hoCUNRpRF0l9w1AE5R1L7CCjh+4kIS9pr3yJJOpj2DgdxDPZvUV 0g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36ey7h7fw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 09:46:03 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 51C9710002A; Thu, 4 Feb 2021 09:46:03 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 42E2522AE46; Thu, 4 Feb 2021 09:46:03 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 4 Feb 2021 09:46:02 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v3 03/15] rpmsg: char: export eptdev create an destroy functions Date: Thu, 4 Feb 2021 09:45:22 +0100 Message-ID: <20210204084534.10516-4-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> References: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-04_03:2021-02-04,2021-02-04 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + +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); }; 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