Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp711740imm; Wed, 13 Jun 2018 07:11:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKMcj7FVgbcIklXrlxW4a2k+qGgAjHo+Hjlo2XXuf+LtcGURhsUZfp39qa4lnUy/CQoWk3A X-Received: by 2002:a63:842:: with SMTP id 63-v6mr4379307pgi.406.1528899095777; Wed, 13 Jun 2018 07:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528899095; cv=none; d=google.com; s=arc-20160816; b=rneHqzR7Alp0I2NjmfDTzyqHO4HGdHP/49ayzncTd+idieWF9L7hpFYPaLjMybuX7E bC2N5TRDleAADStriSl/FyKAgT+Ygn2FKt+bbzmGSp1DhpTl9ZAkpgNzYw0mLEy0VTLj SuBUbHbeKCSC5hizGi0BPkfuSUla3DLMHRQ5gP2TCbw3l7LbZGfEos/wI7rYhnLOP3D+ bbCKjKgfcxU0ccefBrn5efehdz0ZzP9RTrB/61cWQtBCnMKLK/dS/5htkS0PjyZADzm6 9rqwnf4R7Vy4tnvLgHZmcTy04w3Z38+4xLBdZVHTPIjJK9ExoWR/F/fsYJa17THO4gqo tEDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=xL+Uh8EAtzL1Mi/9S5bztX71AoecwtllfKWwmswHEdo=; b=iC2w+gZdOERfJLsJw+RFh0/JdmywCqtqDbt22JcNKKwCnPbMLLu/WpA6UfxKS5PrdV 50NgInsK8llJq36XlnQ3vLA5BMwXVMyzhBtsjy2cyrwX3nRSy5MMduXL6RAhLd+D6Ttq WY6AafVDSEJiFYju/3T6qiM2QMYBE1N/7/Iu0DaBNtl+V1opddciQBZP7C7kp7VA8JEx PMkuy3yWKz2FYpGfCf+JaT1RAgqW/L3raQ/VqwsZOwKsAhgC6kGyVKJoRTZ7VAzcwxM3 wDa+0+ZHGwDr+imKZEVlmyqu76Zy8mJMYoL70aCHITduCodY8eizRpxUUCH4iq8MKkY9 tj6A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x12-v6si2393128pgt.362.2018.06.13.07.11.20; Wed, 13 Jun 2018 07:11:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935800AbeFMOHU (ORCPT + 99 others); Wed, 13 Jun 2018 10:07:20 -0400 Received: from mail.bootlin.com ([62.4.15.54]:52327 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935606AbeFMOHS (ORCPT ); Wed, 13 Jun 2018 10:07:18 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 7061B20799; Wed, 13 Jun 2018 16:07:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (AAubervilliers-681-1-37-30.w90-88.abo.wanadoo.fr [90.88.156.30]) by mail.bootlin.com (Postfix) with ESMTPSA id 45412203B4; Wed, 13 Jun 2018 16:07:17 +0200 (CEST) From: Maxime Ripard To: hans.verkuil@cisco.com, acourbot@chromium.org, sakari.ailus@linux.intel.com, Laurent Pinchart Cc: tfiga@chromium.org, posciak@chromium.org, Paul Kocialkowski , Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, nicolas.dufresne@collabora.com, jenskuske@gmail.com, linux-sunxi@googlegroups.com, Thomas Petazzoni , Maxime Ripard Subject: [PATCH 2/9] media: cedrus: Add wrappers around container_of for our buffers Date: Wed, 13 Jun 2018 16:07:07 +0200 Message-Id: <20180613140714.1686-3-maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180613140714.1686-1-maxime.ripard@bootlin.com> References: <20180613140714.1686-1-maxime.ripard@bootlin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cedrus driver sub-classes the vb2_v4l2_buffer structure, but doesn't provide any function to wrap around the proper container_of call that needs to be duplicated in every calling site. Add wrappers to make sure its opaque to the users and they don't have to care anymore. Signed-off-by: Maxime Ripard --- .../platform/sunxi/cedrus/sunxi_cedrus_common.h | 12 ++++++++++++ .../media/platform/sunxi/cedrus/sunxi_cedrus_hw.c | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h index ee6883ef9cb7..b1ed1c8cb130 100644 --- a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_common.h @@ -89,6 +89,18 @@ struct sunxi_cedrus_buffer { struct list_head list; }; +static inline +struct sunxi_cedrus_buffer *vb2_v4l2_to_cedrus_buffer(const struct vb2_v4l2_buffer *p) +{ + return container_of(p, struct sunxi_cedrus_buffer, vb); +} + +static inline +struct sunxi_cedrus_buffer *vb2_to_cedrus_buffer(const struct vb2_buffer *p) +{ + return vb2_v4l2_to_cedrus_buffer(to_vb2_v4l2_buffer(p)); +} + struct sunxi_cedrus_dev { struct v4l2_device v4l2_dev; struct video_device vfd; diff --git a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c index 5783bd985855..fc688a5c1ea3 100644 --- a/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c +++ b/drivers/media/platform/sunxi/cedrus/sunxi_cedrus_hw.c @@ -108,8 +108,8 @@ static irqreturn_t sunxi_cedrus_ve_irq(int irq, void *dev_id) return IRQ_HANDLED; } - src_buffer = container_of(src_vb, struct sunxi_cedrus_buffer, vb); - dst_buffer = container_of(dst_vb, struct sunxi_cedrus_buffer, vb); + src_buffer = vb2_v4l2_to_cedrus_buffer(src_vb); + dst_buffer = vb2_v4l2_to_cedrus_buffer(dst_vb); /* First bit of MPEG_STATUS indicates success. */ if (ctx->job_abort || !(status & 0x01)) -- 2.17.0