Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2592552ybg; Fri, 31 Jul 2020 04:51:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBdo7xykFECdF+AS3AM9ljfClAxkZ9NAL2ZKsNDpK72tLFdZZ21jlKAo2eDJfUZ480HF11 X-Received: by 2002:a17:906:4bc5:: with SMTP id x5mr3844118ejv.177.1596196273115; Fri, 31 Jul 2020 04:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596196273; cv=none; d=google.com; s=arc-20160816; b=BpD15LO2wye/pPUR6nZBcFxv38dFkC7bUSBE4RJzDy0yR7wZpcOpKjdGbSTYEbdJpL Alh5zHFySNablzyATetKuFPeYkEHKViexZhQixL2GcivZVhvOKlyxxWIW8tL3Ghocqeo gJqi6UBerGicqV2VHWOzG1cQCuYk5fkZ5/YIZA6qV7d9JtUoBdNew2yaOkTPzwF8Vuhk iyK0qVE3oh6TKxDEcqGnO34jk2OhHShxXovLCGW43s5cHmEEXIZcTKTcRFgltF9NVj/2 YQi8Ga/vwc9Aust7x3JjY3377Db4zk6JWBubBoFzo3gpmlUYIVwd1UqrYAlbhsY4Ar8T kQQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=CCcdvngal7kCWPETsPizoSSdTZ2KU7xlyumYtsHhXpo=; b=Y5ggZP2OyfprZN3+phScfZun662tJnyqPLtNBvRQe5rqnhgYtjKvq033zmudTcHEKq YpKQ/Wcrafl1ZW+dfidXI0bCvboC/wngVgPzxyC+MHe9Mwkqgdr++aUIQb2ZAYE8HvLi VtnfyEsaKQjrCCiR1eCbVDK0/JaP2AfG4+EYUGpQZVbscVf8o8MJfzL8bEDrpIjpat4T vjEZENo21TQvWAYOVLEUiY3QMq4jV4f9cAQh+A0WWNEFPOaQA7HTt8r0zDm9OwBQCmfr tKW/It9KELFVinMgtPxmlf6DN6Civ7/lqG7W8w40yK7UAVg3VtKN7kpLgKjaT2ENOCmE GN4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="0izt/U0y"; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si4851561eje.672.2020.07.31.04.50.50; Fri, 31 Jul 2020 04:51:13 -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=@st.com header.s=STMicroelectronics header.b="0izt/U0y"; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732886AbgGaLsO (ORCPT + 99 others); Fri, 31 Jul 2020 07:48:14 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:34126 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732512AbgGaLrq (ORCPT ); Fri, 31 Jul 2020 07:47:46 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06VBaYq9031435; Fri, 31 Jul 2020 13:47:43 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=CCcdvngal7kCWPETsPizoSSdTZ2KU7xlyumYtsHhXpo=; b=0izt/U0y5atOcXTC6mQr0zBMMDtpZayaH6iGilTS2OAwvJ5iLRgstZHJLoqq5rE9ZXgR yBJKqN+2z5ey8PstZf+ni6Ongw+EZG4RNAmLeRe6pf1Gy4UDp+SPAYrcP3TqQj8MeFZY t7F2kXBh/ENA/nHwdtgPILhGGiajM0pqVVUdJgkxw8XTefbl+vGGFqXrCReVD0YkibSv Mb8n/3GLScFotxhtN+NIr30OuhjOqh/d4JqhpMviGE4sYQ+5VArIt4+hia/Qq06CDPVB BZn0OaigBr5jXNvOTEtISmSVkRLrf3ROvSwB5cEIU57Fmg2T/LPFkP8LslpnicXbqAyP wQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 32gbmgp669-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 31 Jul 2020 13:47:43 +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 85CA410002A; Fri, 31 Jul 2020 13:47:42 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 79C27221061; Fri, 31 Jul 2020 13:47:42 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 31 Jul 2020 13:47:41 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH 2/9] rpmsg: core: add channel creation internal API Date: Fri, 31 Jul 2020 13:47:25 +0200 Message-ID: <20200731114732.12815-3-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200731114732.12815-1-arnaud.pouliquen@st.com> References: <20200731114732.12815-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-31_04:2020-07-31,2020-07-31 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the channel creation API as a first step to be able to define the name service announcement as a rpmsg driver independent from the RPMsg virtio bus. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_core.c | 37 ++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 12 +++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index a6361cad608b..ae7da4a2e528 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -20,6 +20,43 @@ #include "rpmsg_internal.h" +/** + * rpmsg_create_channel() - create a new rpmsg channel + * using its name and address info. + * @rpdev: rpmsg driver + * @chinfo: channel_info to bind + * + * Returns a pointer to the new rpmsg device on success, or NULL on error. + */ +struct rpmsg_device * + rpmsg_create_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + if (WARN_ON(!rpdev) || !rpdev->ops->create_channel) + return NULL; + + return rpdev->ops->create_channel(rpdev, chinfo); +} +EXPORT_SYMBOL(rpmsg_create_channel); + +/** + * rpmsg_release_channel() - release a rpmsg channel + * using its name and address info. + * @rpdev: rpmsg driver + * @chinfo: channel_info to bind + * + * Returns a pointer to the new rpmsg device on success, or NULL on error. + */ +int rpmsg_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + if (WARN_ON(!rpdev) || !rpdev->ops->release_channel) + return 0; + + return rpdev->ops->release_channel(rpdev, chinfo); +} +EXPORT_SYMBOL(rpmsg_release_channel); + /** * rpmsg_create_ept() - create a new rpmsg_endpoint * @rpdev: rpmsg channel device diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 3fc83cd50e98..d5ab286d0e5e 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -20,6 +20,8 @@ /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations + * @create_channel: create backend-specific channel, optional + * @release_channel: release backend-specific channel, optional * @create_ept: create backend-specific endpoint, required * @announce_create: announce presence of new channel, optional * @announce_destroy: announce destruction of channel, optional @@ -29,6 +31,11 @@ * advertise new channels implicitly by creating the endpoints. */ struct rpmsg_device_ops { + struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); + int (*release_channel)(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); + struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, struct rpmsg_channel_info chinfo); @@ -75,6 +82,11 @@ int rpmsg_unregister_device(struct device *parent, struct device *rpmsg_find_device(struct device *parent, struct rpmsg_channel_info *chinfo); +struct rpmsg_device * + rpmsg_create_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); +int rpmsg_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); /** * rpmsg_chrdev_register_device() - register chrdev device based on rpdev * @rpdev: prepared rpdev to be used for creating endpoints -- 2.17.1