From patchwork Thu Sep 1 22:28:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 9309889 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 1F8FB60865 for ; Thu, 1 Sep 2016 22:29:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C26A32952E for ; Thu, 1 Sep 2016 22:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B63662956B; Thu, 1 Sep 2016 22:29:05 +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=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E737A29567 for ; Thu, 1 Sep 2016 22:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753200AbcIAW27 (ORCPT ); Thu, 1 Sep 2016 18:28:59 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:35925 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753149AbcIAW2e (ORCPT ); Thu, 1 Sep 2016 18:28:34 -0400 Received: by mail-pa0-f49.google.com with SMTP id fu3so26012404pad.3 for ; Thu, 01 Sep 2016 15:28:29 -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=ZZWh+IggSPZj/Hl92/1khYUPWVK8A5dEAiLxqdDenFQ=; b=RcwR1BHmc3OCnfvHHb6z3v6DycX70wf2Zscbn2R8UErznPlGAbCJhF+rHBQTHIuM84 UMS1mBeawu1uXdbJXNjSsIuH34QYoVuvyKlgMiLmCElnDLCY2Pskheb5JugLvCxLb0jJ CB3ot/cko8oI/l6Pz9BQkylravu+6bsNcKDAE= 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=ZZWh+IggSPZj/Hl92/1khYUPWVK8A5dEAiLxqdDenFQ=; b=SmCWzsxo20xzCfwFtltyny1g4umYBoYsrhBOGBRX8JCGcRZZlxDRVnV3YXzGyND2OU nIWx30M7t/u4B2TiRNgDmt7BYhBynWcligc3/uMkWkDqfGXEoJL/FsDQkpHeiVS7LL0t Tn4suFYhW6F9v5i9KQzE/SxKGmnHgXQ3bRhg43EhRu1Y03POH+99AF0/Q99P0aD6DoMf QYm71Ch9RRw5vgOKyTGLjcosuzRofCO4Z33Gq1INX1FCq3/J+7fj/iOZYM9IO541EIS3 kBM4HnoGOAS/mAZuzz+uUT/1yuStBEbKvvnHXgcD0J+MMhsoN7ccHeSjILkVu8+P2EPe px6g== X-Gm-Message-State: AE9vXwMGUMT10sBE0LLrPusqOtneMxCodR57LUi7vVNbY9BkpONsgqOHdCTDRW63jjmnyEGu X-Received: by 10.66.222.202 with SMTP id qo10mr30819514pac.76.1472768908832; Thu, 01 Sep 2016 15:28:28 -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 iw10sm8887131pac.14.2016.09.01.15.28.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Sep 2016 15:28:28 -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 v2 14/17] rpmsg: virtio: Hide vrp pointer from the public API Date: Thu, 1 Sep 2016 15:28:06 -0700 Message-Id: <1472768889-3906-15-git-send-email-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> References: <1472768889-3906-1-git-send-email-bjorn.andersson@linaro.org> Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.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. This makes the public structures independant of virtio. Signed-off-by: Bjorn Andersson --- Changes since v1: - Reduced complexity from the move of ops to the public structs drivers/rpmsg/virtio_rpmsg_bus.c | 43 ++++++++++++++++++++++++++++++++-------- include/linux/rpmsg.h | 3 --- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 31cd526f690d..ac2241242188 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -75,6 +75,18 @@ struct virtproc_info { struct rpmsg_endpoint *ns_ept; }; +/** + * @vrp: the remote processor this channel belongs to + */ +struct virtio_rpmsg_channel { + struct rpmsg_device rpdev; + + struct virtproc_info *vrp; +}; + +#define to_virtio_rpmsg_channel(_rpdev) \ + container_of(_rpdev, struct virtio_rpmsg_channel, rpdev) + /* * We're allocating buffers of 512 bytes each for communications. The * number of buffers will be computed from the number of buffers supported @@ -204,7 +216,9 @@ static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev void *priv, struct rpmsg_channel_info chinfo) { - return __rpmsg_create_ept(rpdev->vrp, rpdev, cb, priv, chinfo.src); + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + + return __rpmsg_create_ept(vch->vrp, rpdev, cb, priv, chinfo.src); } /** @@ -235,12 +249,15 @@ __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); + + __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); + struct virtproc_info *vrp = vch->vrp; struct device *dev = &rpdev->dev; int err = 0; @@ -263,7 +280,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); + struct virtproc_info *vrp = vch->vrp; struct device *dev = &rpdev->dev; int err = 0; @@ -298,6 +316,7 @@ static const struct rpmsg_device_ops virtio_rpmsg_ops = { static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, struct rpmsg_channel_info *chinfo) { + struct virtio_rpmsg_channel *vch; struct rpmsg_device *rpdev; struct device *tmp, *dev = &vrp->vdev->dev; int ret; @@ -312,11 +331,18 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, return NULL; } - rpdev = kzalloc(sizeof(*rpdev), GFP_KERNEL); - if (!rpdev) + vch = kzalloc(sizeof(*vch), GFP_KERNEL); + if (!vch) return NULL; - rpdev->vrp = vrp; + /* Link the channel to our vrp */ + vch->vrp = vrp; + + /* Assign callbacks for rpmsg_channel */ + vch->rpdev.ops = &virtio_rpmsg_ops; + + /* Assign public information to the rpmsg_device */ + rpdev = &vch->rpdev; rpdev->src = chinfo->src; rpdev->dst = chinfo->dst; rpdev->ops = &virtio_rpmsg_ops; @@ -455,7 +481,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); + 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 4f9445f71f2f..b4b56b010f71 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; struct rpmsg_device_ops; @@ -115,7 +114,6 @@ struct rpmsg_channel_info { /** * 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 @@ -124,7 +122,6 @@ struct rpmsg_channel_info { * @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;