Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp463283pxv; Thu, 1 Jul 2021 02:06:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhblafPbuCJWYC4yiPdYpG/9MtStT1ACszpuGYgPWR1p/QGkkFUPeSEaf2xaCyBCPi8HYN X-Received: by 2002:a17:907:9496:: with SMTP id dm22mr118476ejc.437.1625130411199; Thu, 01 Jul 2021 02:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625130411; cv=none; d=google.com; s=arc-20160816; b=H9rJ8NICZL4VAU4YhzSNmSSLkyK3JKZd1zb8w8/kiC+sEuNQZgee0twlKr4d++FR0u OvMBx1EtjrnT6ydvlbZDeLuhYyG5TnQT6JKvmUSUDTaZYZ9DbUmdnrztg414xXthCOvx sDXei24/T4H2zKsmCBuvMa7EyjBom8CMaQzF0nCn9SZZjDh4vITm0UTMtALaJC4iUyGm 9lHs5MN31VUUwm6gD1TxeB/NI1DTUT6SSD48VZ95dh3JBn0MbjAs4e2sZeEuiTrmsj5U 69DAv91QRWCthc05pJCfEYO7vqOndOSQ/YFlaHvNVRK+clXoaH3BsWA1anGCVfQb7yqZ z1Hg== 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=RX8nw05HEMw460Kiy8imQQO9gpgLLwLR/oGAGCYUDD0=; b=RG4rrbsc/FooAEKZy7Ui2T2fMvRJEq12RzT+IMel/SdAM/7LsdjsorMe0I96rbhHLq f0Gttnx711tjw2jDlz6e21WGT2ERqXM6dv/fD9ysEGiIvr5TVUApZ4yqrMqZXXUPkwuL Jv8fys1LvB61zQ29CLfWDlacScylTDLU6P281CvHKj7lirFugIe4qzucavTxyHK+fHGX L6w8FgYke1s1+/1EJK/sXcFbRG292hWVYk21WF1EG5Kcrf2TlP6WJSlJrimwEB8459Q5 ajpZ2el3Tk0UStsqW84LWYuKXNpr3EXWNIo/jjXoyuLPGdcPKYeMHAfijU07LFURIrr4 vV8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=2sC6yDeK; 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 w27si23084201ejk.544.2021.07.01.02.06.27; Thu, 01 Jul 2021 02:06:51 -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=@foss.st.com header.s=selector1 header.b=2sC6yDeK; 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 S235748AbhGAJHL (ORCPT + 99 others); Thu, 1 Jul 2021 05:07:11 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:58418 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235689AbhGAJHC (ORCPT ); Thu, 1 Jul 2021 05:07:02 -0400 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 16190fgS026301; Thu, 1 Jul 2021 11:04:24 +0200 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=RX8nw05HEMw460Kiy8imQQO9gpgLLwLR/oGAGCYUDD0=; b=2sC6yDeKbInunTEN2nz11btzVQ//5LH2WqEAe1iFH2zB+FE8q3uvulL5rUs9uiXjveqi xbRkxpRSHlvohaf/YJawZ4igJiq6Gm7/ZsI7oVq0mczk1l9HSA3joLJhAH6wjNiEFXAG 150oWgUJY0MbhNPQClluA7nknIq1zW7SgXlGrAqh/za9w4a73DeYrE2uaOsbswpuhamn HopzNYfgrxynn2mC5sRKQi6v8F/WT5C+rPLaiKlifokF2MYFPYteVefbN4mI37HFWh/i JgebV00oxGKn7Wqu9r7snXr/WZ4NYH3P5URR5DzUZHR7gguPTMrANTlt1FVWS9rjLMZu AQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 39h1xqay0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jul 2021 11:04:24 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F204810002A; Thu, 1 Jul 2021 11:04:23 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E40952138C8; Thu, 1 Jul 2021 11:04:23 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 1 Jul 2021 11:04:23 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , , Subject: [PATCH v3 2/4] rpmsg: char: Introduce __rpmsg_chrdev_create_eptdev function Date: Thu, 1 Jul 2021 11:04:11 +0200 Message-ID: <20210701090413.3104-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210701090413.3104-1-arnaud.pouliquen@foss.st.com> References: <20210701090413.3104-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-01_06:2021-06-30,2021-07-01 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce the __rpmsg_chrdev_create_eptdev internal function that returns the rpmsg_eptdev context structure. This patch prepares the introduction of a rpmsg channel device for the char device. The rpmsg device will need a reference to the context. Signed-off-by: Arnaud Pouliquen Reviewed-by: Mathieu Poirier --- drivers/rpmsg/rpmsg_char.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index fbe10d527c5c..50b7d4b00175 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -323,8 +323,9 @@ static void rpmsg_eptdev_release_device(struct device *dev) kfree(eptdev); } -int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, - struct rpmsg_channel_info chinfo) +static struct rpmsg_eptdev *__rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, + struct device *parent, + struct rpmsg_channel_info chinfo) { struct rpmsg_eptdev *eptdev; struct device *dev; @@ -332,7 +333,7 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent eptdev = kzalloc(sizeof(*eptdev), GFP_KERNEL); if (!eptdev) - return -ENOMEM; + return ERR_PTR(-ENOMEM); dev = &eptdev->dev; eptdev->rpdev = rpdev; @@ -374,9 +375,10 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent if (ret) { dev_err(dev, "device_add failed: %d\n", ret); put_device(dev); + return ERR_PTR(ret); } - return ret; + return eptdev; free_ept_ida: ida_simple_remove(&rpmsg_ept_ida, dev->id); @@ -386,7 +388,19 @@ int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent put_device(dev); kfree(eptdev); - return ret; + return ERR_PTR(ret); +} + +int rpmsg_chrdev_eptdev_create(struct rpmsg_device *rpdev, struct device *parent, + struct rpmsg_channel_info chinfo) +{ + struct rpmsg_eptdev *eptdev; + + eptdev = __rpmsg_chrdev_eptdev_create(rpdev, parent, chinfo); + if (IS_ERR(eptdev)) + return PTR_ERR(eptdev); + + return 0; } EXPORT_SYMBOL(rpmsg_chrdev_eptdev_create); -- 2.17.1