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: 73939 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1711842qga; Mon, 15 Aug 2016 17:17:55 -0700 (PDT) X-Received: by 10.66.237.10 with SMTP id uy10mr58408661pac.80.1471306672796; Mon, 15 Aug 2016 17:17:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si28990605pft.11.2016.08.15.17.17.52; Mon, 15 Aug 2016 17:17:52 -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 S932486AbcHPARn (ORCPT + 27 others); Mon, 15 Aug 2016 20:17:43 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:33706 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932395AbcHPARf (ORCPT ); Mon, 15 Aug 2016 20:17:35 -0400 Received: by mail-pf0-f177.google.com with SMTP id y134so21319085pfg.0 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=bAuRNBvriiqpExj03ssjZ3DdRhfaIgv5hKbzI0lQznewbTeIzqPwbtJVkKvnmd2uX+ IgLVQBsWS5xmfoEOe8GDUXOgu1b5m3BKbS0+YC+rh6EKrCLvT4ccW87u1y5Y5t8qTsiQ yZCUEN2g7jKyGuEAIvUF9SKmZKXzwGKhcuP7A0btUaxq1lmLdEXOyzoIuKUHfTLhO5J+ QZeCT4bEFTEfy4/HfsAp0znfqCNLzBEVlCevo+Poo6luQa0s4W/sUdxI1VRN4BQb9d6b hfsYRnGRQ52aOSclhEAxRDixog+Zbl7ttGXDV14VNfepWmNXTT+Jha9edbXNUVt0dymx ui+w== X-Gm-Message-State: AEkooutzB2Y20cV/xuvD4bjWsKFjUL/tobSGYQXjsPr5V2U2euLeHRSReU1dobglruylWkrp 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 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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.5.0 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;