Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp548584pxx; Wed, 28 Oct 2020 10:50:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb+EHBuYfibqnriF5HObs0UuJeenxFsBf033UidzmhEkFoYkTgHXhIRY1fjiPJ6DxGNRYu X-Received: by 2002:a17:906:25cc:: with SMTP id n12mr221838ejb.488.1603907401019; Wed, 28 Oct 2020 10:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603907401; cv=none; d=google.com; s=arc-20160816; b=yCtE1OMUggwNlcDnULa7TrgJEcMYMiZb6afInECNNLdw2BshYbwfjGKYOaZkJEMPD8 DPb71DwBqg3/lSovhGEzcn9Gof3gyHOcpi0D62jtLd6nu85jQXNX3VznF8MeozLYuwAP BFQzFur/OPzIhm4MM5eR0k7xMpx97GzQ6d8rxkbRWK/j/5IMf3WVmozUUdaADIquV4Dm J4IQ7s3p338sFuyELKWlJYaA2DIPxkEKAv8QgBAhwtl2j+vojfe4ITZ1AWQQm556cnkU yggxlgzOo8NcwU0R5s6dgA0LvTWxrK10kgelNYzpt+ykmzEfniHAR2dI4x0hceQnbg2m CDHw== 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=dV45urz8CEkil+8k/x+LWNSg/bkz6TIq0p5IEVSCoA0=; b=Cs68est1kwJVilYvN+rXjmlaeOiN3W12yIz3HoKO8GwANoH01BxORjxoROfnTwt0yu UxHm52+L+X8rG4fByRw1HYGZIxWAjKj3S655Ynj1CmkEP16EheogY19QpJ+jCj3wVrUG vT90876kdBYj+7fv9J63fb5PIlbco47iagH6lZp4NR17Sqsj/aBl3ks4CmWMrmN9yhmo DTyxD2sTAvI3GABcQchrpaBeDBk7HhP9MWk7n9kldeR+++IdPKCmjuSPMT+gA4f2HYVf mrw8lDGnsP/xBMnk2d0xSrrqWgeGleG6uoSkSxKohxHMDi9ioLT5hakcr0c5ErF0LXVs zymA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ySnEVeU9; 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 bm13si21671edb.281.2020.10.28.10.49.38; Wed, 28 Oct 2020 10:50:00 -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=@linaro.org header.s=google header.b=ySnEVeU9; 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 S1822818AbgJ0Rwv (ORCPT + 99 others); Tue, 27 Oct 2020 13:52:51 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33713 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1822768AbgJ0Rw1 (ORCPT ); Tue, 27 Oct 2020 13:52:27 -0400 Received: by mail-pf1-f196.google.com with SMTP id j18so1368190pfa.0 for ; Tue, 27 Oct 2020 10:52:27 -0700 (PDT) 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=dV45urz8CEkil+8k/x+LWNSg/bkz6TIq0p5IEVSCoA0=; b=ySnEVeU9jWeTb0qiecTxIE+ABKsLlD1d4Cemwq17LC264SVdVApeXPBoN/wKIBTrKK R8IcREor0bMosp53Ls1CGAlHZVQnJidYjycMx1wcUxOexQaKCpsMOy3PTMubpGxy+Kcr ClDA56SZs/W+In5LkLtQFr+1a2VHzsmij7jrA3BXeWFNV+bHzuWxFDdUpVmTK5vGhpHN qwJjkcsum7U2BAEaSwLztyx95QqMZ/HyXRv1BQSjGfZ6imvCF/0I/sv0SkBqD+POIFsO 0WrU/O+j8U9Odzvg9ZvNtilBR1AWS0q9WJRjZd4NNuqrgr3vAUrleyhOA8GtSIpQHTGl ZCFg== 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=dV45urz8CEkil+8k/x+LWNSg/bkz6TIq0p5IEVSCoA0=; b=ltIrtkSF3mdGQ3jX2hAeEvhWnFqblbH63oeDdrARIb7RARFON2C7pZjbTVPHbG4ghS 52HYPElc1+M9o5KyaLZGCNgULrAF/FXb1NB7NVM5MUQS3pbi8lx+A9m2ErI1xaUtm2eD AYvOvqLtcOqUohcsyLYd02HinbKj1dkGBBnms0hx+gimlhJMx7Y5HM9kDhYv+JClyh9j pLsjWCIDuQnMh2R+PYNMTfWBAbTS2UCEC0LLjBvdyZkNKI0mOwIdGgYi64ZM1pXnFCYQ DNONLhhmztD+7KNO/ltQVkP1pi9706+KYMG0vT9xTC82/EGcUpNbcjZ5SfCJ2xuUQsav xIuQ== X-Gm-Message-State: AOAM533hNQLRlDgDUmgSMVOqf+ur/8mAFyGb+KpBedBfOynD9M0MyIQ9 XKeM7ztVL4/fiEnIyG1cdm/Ojg== X-Received: by 2002:a63:e642:: with SMTP id p2mr2882647pgj.79.1603821146803; Tue, 27 Oct 2020 10:52:26 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id r8sm2761225pgl.57.2020.10.27.10.52.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 10:52:26 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: guennadi.liakhovetski@linux.intel.com, arnaud.pouliquen@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/8] rpmsg: core: Add channel creation internal API Date: Tue, 27 Oct 2020 11:52:15 -0600 Message-Id: <20201027175218.1033609-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201027175218.1033609-1-mathieu.poirier@linaro.org> References: <20201027175218.1033609-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..6381c1e00741 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..810dd95cc9bd 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