From patchwork Tue Aug 16 00:17:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9282439 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 29619607FD for ; Tue, 16 Aug 2016 00:26:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18C9928E8E for ; Tue, 16 Aug 2016 00:26:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC7F28E90; Tue, 16 Aug 2016 00:26:38 +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 A9A1228E8E for ; Tue, 16 Aug 2016 00:26:37 +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 1bZSBp-00023J-FG; Tue, 16 Aug 2016 00:25:09 +0000 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bZS4p-0003SP-Qj for linux-arm-kernel@lists.infradead.org; Tue, 16 Aug 2016 00:18:05 +0000 Received: by mail-pf0-x236.google.com with SMTP id p64so21404466pfb.1 for ; Mon, 15 Aug 2016 17:17:35 -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=mV6bRuPf57JZMkrpIlSLK2bje6rdLCGBlsX6fOG2N9Q=; b=IdrKzw1y0CDovZlBozqJZ9o2u81h8rd5u15kTCYc6emMQ3hJAgwoFTDe2emAZqRzSK Or1E9onBqP+ROwT3MnLZH6THdx1Ylixl/SH7nv9JHtDxdyQHarSaXXaU2A3VV4Z+tvSA LKyIT9sn+up/4kgLUGZPnBkNGcejper2MisqY= 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=mV6bRuPf57JZMkrpIlSLK2bje6rdLCGBlsX6fOG2N9Q=; b=Vvg64uT7Og3VCzDlWgV68OEDfY/Sic1m6WFAF07EdOpSBwgZ4ZG8A6EahN5PLes83M vTWMI/7EPkWewyajrcf6ry/zJ6Ef1+2jOY35Ce6fzsDG16OIbnk6IrZuETyLGqFOMazw hgIyzrI1duGKrMVcxEa48WkmPCjzmGo4KA/4OYyy18a7uapQf15Wy+1AWApLiHaF9ovo Hmo3cJ2LNGMkXgFH79WrGFl6/LruSVUsGUkzd0i9i8kwAPNDAIxKcE33cH5JBwELK0wY Kv1O3YVmpjMTP0ADdVZkgZumwGpusVGrvJ80a+RMADrAon1N0LiiGlmz22ho9Xj8xgSy DOHw== X-Gm-Message-State: AEkooutZIFAYZYpP8bmsaqZXVJzvKh0I6BgmutHPQe7CoAtifmZFcTAgwsdmoHIh1gnbeAiC X-Received: by 10.98.149.22 with SMTP id p22mr6075319pfd.88.1471306654878; Mon, 15 Aug 2016 17:17:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 17:17:34 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Subject: [PATCH 10/14] rpmsg: virtio: Internalize vrp pointer Date: Mon, 15 Aug 2016 17:17:16 -0700 Message-Id: <1471306640-29917-11-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_171756_172380_A0FDADC3 X-CRM114-Status: GOOD ( 15.35 ) 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 Create a container struct virtio_rpmsg_channel around the rpmsg_channel to keep virtio backend information separate from the rpmsg and public API. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/virtio_rpmsg_bus.c | 45 ++++++++++++++++++++++++++++++---------- include/linux/rpmsg.h | 3 --- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index d08facbcd30a..6ad4c657aaf4 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -75,6 +75,21 @@ struct virtproc_info { struct rpmsg_endpoint *ns_ept; }; +/** + * @vrp: the remote processor this channel belongs to + */ +struct virtio_rpmsg_channel { + struct rpmsg_channel rpch; + + struct virtproc_info *vrp; +}; + +static inline struct virtio_rpmsg_channel *to_virtio_rpmsg_channel(struct device *d) +{ + struct rpmsg_channel *rpch = to_rpmsg_channel(d); + return container_of(rpch, struct virtio_rpmsg_channel, rpch); +} + /* * We're allocating buffers of 512 bytes each for communications. The * number of buffers will be computed from the number of buffers supported @@ -191,7 +206,8 @@ static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev rpmsg_rx_cb_t cb, void *priv, u32 addr) { - return __rpmsg_create_ept(rpdev->vrp, rpdev, cb, priv, addr); + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(&rpdev->dev); + return __rpmsg_create_ept(vch->vrp, rpdev, cb, priv, addr); } /** @@ -222,12 +238,14 @@ __rpmsg_destroy_ept(struct virtproc_info *vrp, struct rpmsg_endpoint *ept) static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept) { - __rpmsg_destroy_ept(ept->rpdev->vrp, ept); + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(&ept->rpdev->dev); + __rpmsg_destroy_ept(vch->vrp, ept); } static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev) { - struct virtproc_info *vrp = rpdev->vrp; + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(&rpdev->dev); + struct virtproc_info *vrp = vch->vrp; struct device *dev = &rpdev->dev; int err = 0; @@ -250,7 +268,8 @@ static int virtio_rpmsg_announce_create(struct rpmsg_device *rpdev) static int virtio_rpmsg_announce_destroy(struct rpmsg_device *rpdev) { - struct virtproc_info *vrp = rpdev->vrp; + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(&rpdev->dev); + struct virtproc_info *vrp = vch->vrp; struct device *dev = &rpdev->dev; int err = 0; @@ -292,7 +311,7 @@ static const struct rpmsg_channel virtio_rpmsg_ops = { static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, struct rpmsg_channel_info *chinfo) { - struct rpmsg_channel *rpch; + struct virtio_rpmsg_channel *vch; struct rpmsg_device *rpdev; struct device *tmp, *dev = &vrp->vdev->dev; int ret; @@ -307,15 +326,18 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, return NULL; } - rpch = kzalloc(sizeof(*rpch), GFP_KERNEL); - if (!rpch) + vch = kzalloc(sizeof(*vch), GFP_KERNEL); + if (!vch) return NULL; + /* Link the channel to our vrp */ + vch->vrp = vrp; + /* Assign callbacks for rpmsg_channel */ - *rpch = virtio_rpmsg_ops; + vch->rpch = virtio_rpmsg_ops; - rpdev = &rpch->rpdev; - rpdev->vrp = vrp; + /* Assign public information to the rpmsg_device */ + rpdev = &vch->rpch.rpdev; rpdev->src = chinfo->src; rpdev->dst = chinfo->dst; @@ -453,7 +475,8 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, u32 src, u32 dst, void *data, int len, bool wait) { - struct virtproc_info *vrp = rpdev->vrp; + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(&rpdev->dev); + struct virtproc_info *vrp = vch->vrp; struct device *dev = &rpdev->dev; struct scatterlist sg; struct rpmsg_hdr *msg; diff --git a/include/linux/rpmsg.h b/include/linux/rpmsg.h index 3d0ff950c0d6..a5679b9b6102 100644 --- a/include/linux/rpmsg.h +++ b/include/linux/rpmsg.h @@ -95,7 +95,6 @@ enum rpmsg_ns_flags { #define RPMSG_ADDR_ANY 0xFFFFFFFF -struct virtproc_info; struct rpmsg_device; struct rpmsg_endpoint; @@ -103,7 +102,6 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); /** * rpmsg_device - device that belong to the rpmsg bus - * @vrp: the remote processor this channel belongs to * @dev: the device struct * @id: device id (used to match between rpmsg drivers and devices) * @src: local address @@ -112,7 +110,6 @@ typedef void (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32); * @announce: if set, rpmsg will announce the creation/removal of this channel */ struct rpmsg_device { - struct virtproc_info *vrp; struct device dev; struct rpmsg_device_id id; u32 src;