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: 75245 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp536378qga; Thu, 1 Sep 2016 15:29:07 -0700 (PDT) X-Received: by 10.66.246.134 with SMTP id xw6mr30782693pac.35.1472768947140; Thu, 01 Sep 2016 15:29:07 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g87si7699014pfd.62.2016.09.01.15.29.06; Thu, 01 Sep 2016 15:29:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753209AbcIAW2o (ORCPT + 8 others); Thu, 1 Sep 2016 18:28:44 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:34867 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753153AbcIAW2e (ORCPT ); Thu, 1 Sep 2016 18:28:34 -0400 Received: by mail-pa0-f43.google.com with SMTP id hb8so33833449pac.2 for ; Thu, 01 Sep 2016 15:28:34 -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=atyrAtBx0pw89cteAlKLS27w3j937UKWIsMenpDS9DQgqK9ONkrLEM/hX3Ixz3nI5B 20irFGZbBi6bHtwku+Z0shliSel2qz5wU/LtYxnodBcHAOuQilciIMRUCJi+EW+79d73 gbj6XIpUvFGX07nJnnh7/3S+5XjHSw5Skq2i+YiL73UFbxk6Gnbfp5GKTR+OFxVbCUim C2fsU22leObpHPNm3pbOyQM5tHdlJhy+d8vfv+3cWgDtmPempB8C5Bf2J59H2kwDGxgb micDSwQpFkJ1zcZ3s5fFydbt+0c9ttpucs5yKRCQNn5IDrCWmW9V/scN9dU/DA4UdBNm +TsA== X-Gm-Message-State: AE9vXwMXh8OxvS/edt5rCuEy9E3vnZWc8snTSotOuHp1VCc59bYgouNCtaIDHdPJvM3ggsqp 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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. 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(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;