From patchwork Tue Aug 16 00:17:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9282429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC02D607FD for ; Tue, 16 Aug 2016 00:24:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB87E21050 for ; Tue, 16 Aug 2016 00:24:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A03FC28E8E; Tue, 16 Aug 2016 00:24:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B60121050 for ; Tue, 16 Aug 2016 00:24:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZS9N-0008BO-Nr; Tue, 16 Aug 2016 00:22:37 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZS4s-0003Sp-NR for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2016 00:18:07 +0000 Received: by mail-pf0-x22f.google.com with SMTP id x72so21368509pfd.2 for ; Mon, 15 Aug 2016 17:17:37 -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; bh=w9gShR7VQNFvDa++WLMlTJ/M2Yr3TbSIAJu9VEIEx0U=; b=R1d9EsRjkNYYv5YIXBX9/lS7RS20VlGcSDyMoPPQOzQV6YzgfxSdkEqxoqXf0n0Q+a AqgefgkWVxlG6Nqltr2XQpM0sTCa//NNitNc+hMKZ9teE3WA8l6LY7cFc9m+tWxjQwmk TqlObcMJySHOAi4f44/8RqVoBpk2DSRBE8sYk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w9gShR7VQNFvDa++WLMlTJ/M2Yr3TbSIAJu9VEIEx0U=; b=RDYOnFygMvAUY3N5e9oBc741r/j2gPreWY2yD7MyAeto7lOhg0t1m3Kwvv9gH0chz6 bunW3yhg6F9k4zio0BgSzoMsHJxJZPvqJrLScLOtN6wL0I2AfEAMYMKCTwZ8tl5KVNyF RBLzZFRPqqroi9sZKgTtqzfjWdZoR4Ff/BtukvE2yHONNX60mujv7jdDZ2cAbxV692vB jbbs6eg4Y4pxQeKn/4MdTFHpcCF0Q/8ir7mhCCehGKy43AowIgqoBZv3lUekHOMrg1eb SZTIjq7uXfhNhiANd42LvG/kk6rOc0QsFxsdmJC9yTDtHgOV8rqxoPEDT7v+tT4P6+LG vRkQ== X-Gm-Message-State: AEkoouv5Ec6fYeLmmiAIawSPAwhYD1mRm3fR/SVWbKOTx6c4ZWvWrEuKx+TMbMMWYCsfDr3g X-Received: by 10.98.129.5 with SMTP id t5mr1079994pfd.32.1471306657022; Mon, 15 Aug 2016 17:17:37 -0700 (PDT) Received: from localhost.localdomain (ip68-111-223-48.sd.sd.cox.net. [68.111.223.48]) by smtp.gmail.com with ESMTPSA id p187sm34047931pfb.5.2016.08.15.17.17.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 17:17:36 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH 12/14] rpmsg: Make rpmsg_create_ept() take channel_info struct Date: Mon, 15 Aug 2016 17:17:18 -0700 Message-Id: <1471306640-29917-13-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1471306640-29917-1-git-send-email-bjorn.andersson@linaro.org> References: <1471306640-29917-1-git-send-email-bjorn.andersson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160815_171759_087897_BCD21EE7 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some rpmsg backends does only support point-to-point "links" represented by a name. By making rpmsg_create_ept() take a channel_info struct we allow for these backends to either be passed a source address, a destination address or a name identifier. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/rpmsg_core.c | 12 +++++++++--- drivers/rpmsg/rpmsg_internal.h | 14 +------------- drivers/rpmsg/virtio_rpmsg_bus.c | 5 +++-- include/linux/rpmsg.h | 15 ++++++++++++++- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 6f7cc79f7229..54df4f77d72c 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -78,11 +78,12 @@ * Returns a pointer to the endpoint on success, or NULL on error. */ struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *rpdev, - rpmsg_rx_cb_t cb, void *priv, u32 addr) + rpmsg_rx_cb_t cb, void *priv, + struct rpmsg_channel_info chinfo) { struct rpmsg_channel *rpch = to_rpmsg_channel(&rpdev->dev); - return rpch->create_ept(rpdev, cb, priv, addr); + return rpch->create_ept(rpdev, cb, priv, chinfo); } EXPORT_SYMBOL(rpmsg_create_ept); @@ -337,10 +338,15 @@ static int rpmsg_dev_probe(struct device *dev) struct rpmsg_channel *rpch = to_rpmsg_channel(dev); struct rpmsg_device *rpdev = to_rpmsg_device(dev); struct rpmsg_driver *rpdrv = to_rpmsg_driver(rpdev->dev.driver); + struct rpmsg_channel_info chinfo = {}; struct rpmsg_endpoint *ept; int err; - ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, rpdev->src); + strncpy(chinfo.name, rpdev->id.name, RPMSG_NAME_SIZE); + chinfo.src = rpdev->src; + chinfo.dst = RPMSG_ADDR_ANY; + + ept = rpmsg_create_ept(rpdev, rpdrv->callback, NULL, chinfo); if (!ept) { dev_err(dev, "failed to create endpoint\n"); err = -ENOMEM; diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 54083bf54d14..1ac96d7ac363 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -23,24 +23,12 @@ #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) -/** - * struct rpmsg_channel_info - internal channel info representation - * @name: name of service - * @src: local address - * @dst: destination address - */ -struct rpmsg_channel_info { - char name[RPMSG_NAME_SIZE]; - u32 src; - u32 dst; -}; - struct rpmsg_channel { struct rpmsg_device rpdev; struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, - u32 addr); + struct rpmsg_channel_info chinfo); void (*destroy_ept)(struct rpmsg_endpoint *ept); int (*send)(struct rpmsg_endpoint *ept, void *data, int len); diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index a284b48285a1..d39e381bc596 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -256,10 +256,11 @@ free_ept: static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, - void *priv, u32 addr) + void *priv, + struct rpmsg_channel_info chinfo) { struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(&rpdev->dev); - return __rpmsg_create_ept(vch->vrp, rpdev, cb, priv, addr); + return __rpmsg_create_ept(vch->vrp, rpdev, cb, priv, chinfo.src); } /** diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index db409a8e3178..bdd1a2285733 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -49,6 +49,18 @@ struct rpmsg_endpoint; typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); /** + * struct rpmsg_channel_info - internal channel info representation + * @name: name of service + * @src: local address + * @dst: destination address + */ +struct rpmsg_channel_info { + char name[RPMSG_NAME_SIZE]; + u32 src; + u32 dst; +}; + +/** * rpmsg_device - device that belong to the rpmsg bus * @dev: the device struct * @id: device id (used to match between rpmsg drivers and devices) @@ -120,7 +132,8 @@ int __register_rpmsg_driver(struct rpmsg_driver *drv, struct module *owner); void unregister_rpmsg_driver(struct rpmsg_driver *drv); void rpmsg_destroy_ept(struct rpmsg_endpoint *); struct rpmsg_endpoint *rpmsg_create_ept(struct rpmsg_device *, - rpmsg_rx_cb_t cb, void *priv, u32 addr); + rpmsg_rx_cb_t cb, void *priv, + struct rpmsg_channel_info chinfo); /* use a macro to avoid include chaining to get THIS_MODULE */ #define register_rpmsg_driver(drv) \