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: 73945 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1712156qga; Mon, 15 Aug 2016 17:19:03 -0700 (PDT) X-Received: by 10.67.16.42 with SMTP id ft10mr38048549pad.133.1471306743048; Mon, 15 Aug 2016 17:19:03 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d186si29013669pfc.72.2016.08.15.17.19.02; Mon, 15 Aug 2016 17:19:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932578AbcHPATB (ORCPT + 27 others); Mon, 15 Aug 2016 20:19:01 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36098 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932421AbcHPARh (ORCPT ); Mon, 15 Aug 2016 20:17:37 -0400 Received: by mail-pf0-f181.google.com with SMTP id h186so21305017pfg.3 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=NsK9MAafZ3Ji6k/qD+pjn3PB0RVcNSx1dEitxqN1pItcZmU+zw5pe/+l+Zs/U+XwdG xl7AtQ1/U8VAf+pRoSVGSRX/TiX2jvVeqxMtBXkWkyqGRiMTpqibWmQhJyvXGRsOtGPr oEtrQ9RIwEoRJ8h4CLciUZ3zfWNLkkYRkDtUhxVJ3qMALxpt7cXiSa2zizjumwqMxY4z Qlpt50QFq9h2w8a7cDOS20KhWimDrfVMqVOY6Ch8d7QjXS4AM9fxLFw5j8KFXpmo2J/9 9Y5AxPZc0bLTLhgd8+xoAc0lqGXg6qpQzdz/W5X1Hr1EjRzzMXxSNaiBp1zYTqIb4Ld3 VPoA== X-Gm-Message-State: AEkoousvqTfzTB2gw+OFo3BJdctuhI9dbzNDuGimLXvd7SsW6XZ1yztaE9ywFHU5wgD0/W8h 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 Cc: linux-remoteproc@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.5.0 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) \