Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7939061pxb; Fri, 19 Feb 2021 03:24:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwINpcMg1y6F+q+mrZbdlPnA1s/wjFEXbeVY3c5ZpJDv77kJygkKNnpxlQ1OXH4LDVaK/xM X-Received: by 2002:aa7:cb49:: with SMTP id w9mr5815361edt.375.1613733842845; Fri, 19 Feb 2021 03:24:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613733842; cv=none; d=google.com; s=arc-20160816; b=g6+f0fP3JLVKagWGhv/QxW75y3qEJKxMykMD54X42JgyO7nsumrKkzFpAJyTiTdf7K hdvWfWPyNE1ovedW1tEaD3/leNS+DpHIKmNrwXB95gdFZq72/gMmC7NyLJTZUGQn+lGY 8bUKn1unzoNE72DDCPe1pO0SscnZe2ClbOa+YyvMEh3KbRqVGydHABgL7CY1NdO9PMe/ grddRHhTD+2PkC1a0k00iIUsU+wi5I4ikCBlqchuS0wrlppFimNNhWMa5nPh7i5voBzt uYmnZlAf5joBsHHhBFSOzwn0VyjhmxCozcShwN5CmhEDbXDVTi3mhQwYZEYcivbXtCq+ qyww== 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=l7Dh0+BXC8SjiWj+8QBzLH1QxnLopiVI0ehJaOLC55v/3UOcjr6rcxjW9bKX507hVy OYJY8KcUJ7ji7Xm3u/yT8MDB/NNjY29zyzBbtL3/AaOXMLLlM4ggyCcCqFJSU+4f6z1R PK+vtB+6aEyeblz3JEYnGBSbKG5+yG393XpIWVvYxplwHOHop6FmJRE6FxTJ6EklN0+3 TckcCQ2PjLnB6MU69/MlXSj/MMTswbXPu/65KHmCwhpOsxEgrTFplP0IV9+o/rVBw2UE F9Qwq4u580qL2aTiMF4iye1nE7Q184LdfC629sz37rdjGf7p9BF/cskdHoH5Qq1D+pM6 jAvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=aRZnhjCV; 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 cs10si5263773ejc.200.2021.02.19.03.23.38; Fri, 19 Feb 2021 03:24:02 -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=aRZnhjCV; 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 S230038AbhBSLVI (ORCPT + 99 others); Fri, 19 Feb 2021 06:21:08 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:57826 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbhBSLSt (ORCPT ); Fri, 19 Feb 2021 06:18:49 -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 11JBGJ6x030425; Fri, 19 Feb 2021 12:18:02 +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=aRZnhjCV7fCqPryW5dpMpBHXoY+zxjJTokMDgdgwwgFWXtz7GteAgBaT2dsksWuPIMfb SPRanWrbQMXktm+gFdLTtURPQ7YLmZQUBaG6m7044NpWgUF7ZLOGM8/3MJrxABS9/t/M ItblN4H8nI5fzuSxdznwOJnsNqafR6G/t03WKGTrgqPzybV9EYCPSg76biJfpGCqNl++ yfMDj325GxVGKHfnqplZ0Lh1vBo+ryNDyNZ1Cq1aT9EmhFCTy8IjSFkr33v2nnTnEs6T pPZb5ZhluRnCuoaP1ESXhBmlcQx12dYntumWNVORNqWvYZne8F9QezTQ6o7pEjFhML4d CA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36p7072su4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 19 Feb 2021 12:18:02 +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 30DF110003B; Fri, 19 Feb 2021 12:18:02 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 23A4B2266D8; Fri, 19 Feb 2021 12:18:02 +0100 (CET) Received: from localhost (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 19 Feb 2021 12:18:01 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v5 04/16] rpmsg: char: export eptdev create an destroy functions Date: Fri, 19 Feb 2021 12:14:49 +0100 Message-ID: <20210219111501.14261-5-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> References: <20210219111501.14261-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-19_04:2021-02-18,2021-02-19 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