Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5747309pxj; Wed, 23 Jun 2021 08:09:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFotc5QjniuvWaPWXD0hcnCRoWdaL0uJ0Pe9UZrhgTZ32KhWsA1uVEZYjlRCIn9JP4KiWK X-Received: by 2002:a5d:96c6:: with SMTP id r6mr21548iol.25.1624460976265; Wed, 23 Jun 2021 08:09:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624460976; cv=none; d=google.com; s=arc-20160816; b=L4tt1121zpPq9fq+HiRA4Rf/Tn0oEkrSp/GEYTDiQZIMvhKeLUsFpKlx8oil/VhGa3 B8NL9t8jI4lO5uOqxISH5TY1phJdiEm8JQyJ8xf1O9Y0bVz8/4Mz4SmYpKAwdYwqduxJ tjYlcnBvTB7B2TL0TQ3s4Gc2rxIVTp4qdoo0+0sNn7ej5ExL2r4oSRTEO89MCfoPcqBf bi8FN5mpkC0VmClsUv7k2diIYN79FzSSjvBXiFfa5coBrAqx69SPmyf7zkPewXGOA4y6 n5bkX+iWne6NjM7CYMLlRkhh6M98YglaqzzV9CnOAYjQQfwOL9U3HWT3L90zsOlGVoxv l6ug== 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=b0zjH/4y7K0iPxpv1dS83o+a843i2XBRv48m2T42OcY=; b=eDKuzXhQIukQGUAOfP4rD5k7kJsrmL8uHIOPhvhDSnrrxSuPUUC476hhoPSF/MBS0Q pTmlS1DNQhmaikNEuxJ+ovk6xdwBSR3kkk2/IDQkAIQzLeUaVdKeOVpeIH2p1PPB4f4Z n2FXgbOi6EoZcPSI2EObJ7fMnEG4gwzqX6sijNopvFQzq6NWz2aLmCGvWEmKqfIeIE2R JG/ZYUe+MHa7HtzsBwn7m4cZFu0L6VITwQy/AiD+c5BMcZqjarb0K8bIs5r29USZIG9h yNZzg9NTOAAFvqjU3uq3TE9vS5jtccnuyhFaJIVbLWnXI5gnwtwFjD0qQArcUgyJcIAv ZnHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=SrJjmLdu; 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 d13si223754jaq.82.2021.06.23.08.09.24; Wed, 23 Jun 2021 08:09:36 -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=SrJjmLdu; 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 S231379AbhFWPKs (ORCPT + 99 others); Wed, 23 Jun 2021 11:10:48 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:25804 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbhFWPKj (ORCPT ); Wed, 23 Jun 2021 11:10:39 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15NF20CU031734; Wed, 23 Jun 2021 17:08:12 +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=b0zjH/4y7K0iPxpv1dS83o+a843i2XBRv48m2T42OcY=; b=SrJjmLduFAKfsMdjbMNiX2qsGYx6dzCGQ0nkOFJFFaumc5VdiH1tR+Biv90Nc2htGmrA +zLWNdsjH0Y1vfB00TIxDX9i5QBQoSlBs9uLD//brW1l6bJ1cwRYOwexUWzLdhJ9kvnB +X1EtiGU8M0xyhPUAqIYJ551qY1f2A/5MeUOu9Bnbmz/tWSJGyDINZFkfeh75MXKUeaf Ak2FrM3YSX6p9mwvoPEMK8LiG9DHtnbww3J3MeOD2H+6tIAVInpL/L0cNuLVICU1xDOi ZIen0bLeLwAVKXtqJx7EEQ0asBcgJTXEcQy8qG8ofNPft9C86SX44DmwRcG1kaWsAYpY Cw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 39bwdckhpw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Jun 2021 17:08:12 +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 37DA8100038; Wed, 23 Jun 2021 17:08:12 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 250D022D186; Wed, 23 Jun 2021 17:08:12 +0200 (CEST) Received: from localhost (10.75.127.48) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 23 Jun 2021 17:08:11 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , , Subject: [PATCH v2 2/4] rpmsg: char: Introduce __rpmsg_chrdev_create_eptdev function Date: Wed, 23 Jun 2021 17:05:02 +0200 Message-ID: <20210623150504.14450-3-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210623150504.14450-1-arnaud.pouliquen@foss.st.com> References: <20210623150504.14450-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) 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-06-23_09:2021-06-23,2021-06-23 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 --- 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