Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp847721pxb; Thu, 5 Nov 2020 14:52:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKLMq+kvBrGcTQOvr6CeHQoi/SV03qWD5w4hVqmMh8jMmRtaWLcJWalDRv6+IGURCCd9xc X-Received: by 2002:a17:906:b255:: with SMTP id ce21mr4846629ejb.137.1604616743920; Thu, 05 Nov 2020 14:52:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604616743; cv=none; d=google.com; s=arc-20160816; b=KomSyGudPuosfZQnQxDm+1N7KxnE6DXvtMCnn8LU8KPGADz4tPvJCEj6iBC8jOF6mf f6GhD05hMbFscn/3Dd78cJ2r+Y0dZsSPTlPkeSSFvmVvk+eqQntyT8ukYnU+AbrBi6Q6 4YTP/ud9uqRPEP6CNFDdQ8Pqo/8VnMCzDqwN9I82liiOjPg20HWu5PVeIa5yDWTIdx2x U76PmDDv1Lc0PUvTvm2W/ZJXZfI9hSx7DexE/vFX1yRbJ6ZfsglZmjgbbDfJ9R7rmnqA 9LmszvRTd3xd78MEKoMO+ia5SSp+7TUgbrJ0U4pZdSWKyZQWT9GO7mvhuyaVcNWziQ9d zsJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YpJGL4iVaQpB7OmyOGqz/Jf0POXHK+Nggf2uFVT9Buw=; b=iX+pJH/7P91kY2vhpDK4UDFcVItW6eZdU2YmmjXX17m84JwLsTFWCTcjRfEXggLOOI ucbI4+JVMnwS0CeK4b3ceeFTTXajiR56rmZyJjeVT24HxteyA82W66wVqqKhBYxvTCUw J6g6+7G1F5qT2to/N6+PSMPfKN5VATxZglwDhb3oOZWtS4i45LaJghQYpnmE1q0PiamJ 9En9+AewkSj9BhBwB6QFG4DjIm21rCDHFCmVScn9mlPIFyMuFYI+ez2GaEGhetNVNv2W 856Oex9e1DvkVjUg3NVh/kslaBMzMGBY8oYhKCiDk9jgxAnMVQ1rPZ1WARzQuBcsRv8G 6dHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dg+UmQq4; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt25si2408343ejb.507.2020.11.05.14.52.01; Thu, 05 Nov 2020 14:52:23 -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=@linaro.org header.s=google header.b=dg+UmQq4; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732409AbgKEWuj (ORCPT + 99 others); Thu, 5 Nov 2020 17:50:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732461AbgKEWug (ORCPT ); Thu, 5 Nov 2020 17:50:36 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A53C061A4C for ; Thu, 5 Nov 2020 14:50:35 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id w4so2370038pgg.13 for ; Thu, 05 Nov 2020 14:50:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YpJGL4iVaQpB7OmyOGqz/Jf0POXHK+Nggf2uFVT9Buw=; b=dg+UmQq4rnbB69SgYtfcIvF6lUBkAgAB6O6+PdTlzR9M2yWMrtGZzEG9Fxm5w3TSmn kWibwcXh7r+zTrI19GDA4rKKH46l0c5JIdZ7wizOU5wLB9BVZXE+2Xr7wQKC2+zsLpmG L4+tHyNGy+GMTfsb/VF68kXIpsZKIF0RfVIRODYpi6CullEQREB/lJOLn1ZYpAiVTE5p j35BxlcDXbbI5nsvk+XWku7QEgqlkdlzN/tCUKzzFPkMIHS76W0AhwoZL0A+5ZhixNf2 b2hhwVl9FPcb+2lyR9UG2FPoLn4OF0NkdlN1z9Hnsh9iBgTQspXY1lfiRGkOny9tpE5+ imWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YpJGL4iVaQpB7OmyOGqz/Jf0POXHK+Nggf2uFVT9Buw=; b=KdWo7shG1LhzFFUCkTA13CR43HXG9iRAB9OjzERj8GexcfunyPC/hgynvyrgg0+1iT ciMgmRjsS/QrJemKHTuEIK1OUSmNIUOjNpwijgcRbiusl+Mjp3Ih8ZKtqjs3UV+iwNMn rGsesurGzGJN52C5ceRFhVbs9kUREkGPojVUSHqQlVUkGI5XWYPgYXZsEGF2E5zBDm5J S25YoyAmmSNIvAq/9wa+YFLDW4poAW/QNaW/8l54Yz2b00q7dWds2S7a5PdtKzEXQ1/f PrEF1nQigRXZ5eeaXvC+ZlF5nm1Z+DrS6jkiI27EdoWY87gBGceUSUYuAGZrbx+/B2P7 M55A== X-Gm-Message-State: AOAM533O8tH8Xujq2enpXDruAz54gPJLWNa/9PmEZ7ZmysJGxAC9Rk/C IkbmmdEzTBVsq0tCBAP02xriLA== X-Received: by 2002:a05:6a00:14d0:b029:18a:add4:9df7 with SMTP id w16-20020a056a0014d0b029018aadd49df7mr4397025pfu.2.1604616635481; Thu, 05 Nov 2020 14:50:35 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id d145sm3854501pfd.136.2020.11.05.14.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 14:50:34 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: guennadi.liakhovetski@linux.intel.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 5/8] rpmsg: core: Add channel creation internal API Date: Thu, 5 Nov 2020 15:50:25 -0700 Message-Id: <20201105225028.3058818-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201105225028.3058818-1-mathieu.poirier@linaro.org> References: <20201105225028.3058818-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaud Pouliquen 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 Signed-off-by: Mathieu Poirier Reviewed-by: Guennadi Liakhovetski --- drivers/rpmsg/rpmsg_core.c | 44 ++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 10 ++++++++ 2 files changed, 54 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 91de940896e3..e5daee4f9373 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -20,6 +20,50 @@ #include "rpmsg_internal.h" +/** + * rpmsg_create_channel() - create a new rpmsg channel + * using its name and address info. + * @rpdev: rpmsg device + * @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)) + return NULL; + if (!rpdev->ops || !rpdev->ops->create_channel) { + dev_err(&rpdev->dev, "no create_channel ops found\n"); + 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 device + * @chinfo: channel_info to bind + * + * Returns 0 on success or an appropriate error value. + */ +int rpmsg_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + if (WARN_ON(!rpdev)) + return -EINVAL; + if (!rpdev->ops || !rpdev->ops->release_channel) { + dev_err(&rpdev->dev, "no release_channel ops found\n"); + return -ENXIO; + } + + 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..f1de73e0f2d6 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,10 @@ * 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 +81,10 @@ 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.25.1