From patchwork Tue Dec 7 08:08:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 12661267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55026C433F5 for ; Tue, 7 Dec 2021 08:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbhLGIMj (ORCPT ); Tue, 7 Dec 2021 03:12:39 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:40148 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230107AbhLGIMi (ORCPT ); Tue, 7 Dec 2021 03:12:38 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1B75RNPd021901; Tue, 7 Dec 2021 09:08:55 +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=eshN3+K9TXtLzi8d6WwiLBLXYlbm6YlpUT5rkK6+HFs=; b=mnsJwCOp294xxTgYutBgF68k2TPGd05NOlfZB/sO7slFjI4SD07oTL5UcrNO0Ufm6gra sJt7001b4FFWJFujR5+PcaQJpsmQGo6ENo8WUNiBpgIyNWXpjtHYEmXr4WCspzgJLKPZ syDJwueWFOsEf7lK+E9l8uxwS7SlBMdxCJLib9UDIPCdPkRLUMzVfNZWm4t1Pgna3lwi cquiTTo8I/4FQNTrYLfTiPS0VGb0JueCVIxpeG28Lcqi+dcU78+9WT4GGA4K2V9xHSbq 64IuLP0RjAp2nQZvP2fMEua0JtlHc3yd1xlzluMAI4Ic95dbDgSflCFGEzonBTWZGD/f +A== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3ct1fx8rfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Dec 2021 09:08:55 +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 76122100038; Tue, 7 Dec 2021 09:08:54 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6AF012220AE; Tue, 7 Dec 2021 09:08:54 +0100 (CET) Received: from localhost (10.75.127.51) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 7 Dec 2021 09:08:54 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Mathieu Poirier CC: , , , , Subject: [PATCH v8 02/13] rpmsg: Create the rpmsg class in core instead of in rpmsg char Date: Tue, 7 Dec 2021 09:08:32 +0100 Message-ID: <20211207080843.21222-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> References: <20211207080843.21222-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.51] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_03,2021-12-06_02,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Migrate the creation of the rpmsg class from the rpmsg_char to the core that the class is usable by the rpmsg_char and the future rpmsg_ctrl module. Suggested-by: Bjorn Andersson Signed-off-by: Arnaud Pouliquen Reviewed-by: Bjorn Andersson --- drivers/rpmsg/rpmsg_char.c | 11 +---------- drivers/rpmsg/rpmsg_core.c | 15 +++++++++++++-- drivers/rpmsg/rpmsg_internal.h | 2 ++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index f7aa2dd302a5..55f503aaf385 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -27,11 +27,11 @@ #include #include "rpmsg_char.h" +#include "rpmsg_internal.h" #define RPMSG_DEV_MAX (MINORMASK + 1) static dev_t rpmsg_major; -static struct class *rpmsg_class; static DEFINE_IDA(rpmsg_ctrl_ida); static DEFINE_IDA(rpmsg_ept_ida); @@ -561,17 +561,9 @@ static int rpmsg_chrdev_init(void) return ret; } - rpmsg_class = class_create(THIS_MODULE, "rpmsg"); - 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 = register_rpmsg_driver(&rpmsg_chrdev_driver); if (ret < 0) { pr_err("failed to register rpmsg driver\n"); - class_destroy(rpmsg_class); unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX); } @@ -582,7 +574,6 @@ 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); } module_exit(rpmsg_chrdev_exit); diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index f031b2b1b21c..d2129d3e6225 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -20,6 +20,9 @@ #include "rpmsg_internal.h" +struct class *rpmsg_class; +EXPORT_SYMBOL(rpmsg_class); + /** * rpmsg_create_channel() - create a new rpmsg channel * using its name and address info. @@ -650,10 +653,17 @@ static int __init rpmsg_init(void) { int ret; + rpmsg_class = class_create(THIS_MODULE, "rpmsg"); + if (IS_ERR(rpmsg_class)) { + pr_err("failed to create rpmsg class\n"); + return PTR_ERR(rpmsg_class); + } + ret = bus_register(&rpmsg_bus); - if (ret) + if (ret) { pr_err("failed to register rpmsg bus: %d\n", ret); - + class_destroy(rpmsg_class); + } return ret; } postcore_initcall(rpmsg_init); @@ -661,6 +671,7 @@ postcore_initcall(rpmsg_init); static void __exit rpmsg_fini(void) { bus_unregister(&rpmsg_bus); + class_destroy(rpmsg_class); } module_exit(rpmsg_fini); diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index b1245d3ed7c6..416316200bde 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -18,6 +18,8 @@ #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) +extern struct class *rpmsg_class; + /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations * @create_channel: create backend-specific channel, optional