Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1774349imm; Thu, 21 Jun 2018 02:04:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLvQgKxVfKqLVWabR0Adwpo8Nf4IqHdF7axyG0cFZWr7Gkq8BnslqwZ6DLd2BsLEFJlVxMI X-Received: by 2002:a63:3807:: with SMTP id f7-v6mr21853733pga.446.1529571878177; Thu, 21 Jun 2018 02:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529571878; cv=none; d=google.com; s=arc-20160816; b=sSH73GQeBj6yM3mP/1fAYkl+A8gbxzqQEXfUAXDUfDqKPz/nRlr8Z+sUbCi62DBYS7 t/QT2X4oYaTC+J25ztDH4mehAFp6hIGCz5A8wqDU1jSVW2B1yp0CbEAr3fMmFrxqlQMI oUIkkruLOLPrMqMBKbZgXZAc6y7IRcDLKcezeKRDUSkopTWaWkNPsqd1oWsGpG+dGFBP rxId4YVJ509ZLcpzNczTUokpott5wIfp/BthXGuGGrDT6h72oHrcXwX5MBeYVWKnd0RL ZINu/9ljNvc24S4K4o1yGfUUzSmWL0BNie7IN2BGWZtMN1yODehH/EEmb/3mde7mHLlD +1Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=Spv9O5mF2QqfPmsxF0z044WK4qABSXf/9J3W9GU1uJY=; b=eAuvp20KwPkWOPqZ+zW39V+Feb3oqnMdk8IL1c9XFtfdMJuGLBMK+OTxevbNeWhQZB D+/7R41mBp/GQJtXi8fY53pjZIrnCzOgg811Ds5grPhAxUUvAfm+WImVGYZpR2Ej1gYG TUENecDJmHV67jsaJS53cr29SuY1wUtiZuEcm6EYmfoSyCXQJRjWO41kreqQ6c+W7pEE S8kLQVSp6IBQkj6hRY3W6vfD5FIpIJdyeWJKeac/M8gKHvTTpVtYEdunGXvRe8i97HH9 Fz8Z7nHQHRTpV183sQoB6IZGmnHnM0+ofhdk6RM87j9K+FkPWW6LxOF6ZljkVoBOr0oV BP3Q== 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 k12-v6si3593763pgp.561.2018.06.21.02.04.23; Thu, 21 Jun 2018 02:04:38 -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 S932636AbeFUJD1 (ORCPT + 99 others); Thu, 21 Jun 2018 05:03:27 -0400 Received: from mail.bootlin.com ([62.4.15.54]:47206 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754363AbeFUJDX (ORCPT ); Thu, 21 Jun 2018 05:03:23 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id E5CF720CFE; Thu, 21 Jun 2018 11:03:21 +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, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from aptenodytes (AAubervilliers-681-1-50-153.w90-88.abo.wanadoo.fr [90.88.168.153]) by mail.bootlin.com (Postfix) with ESMTPSA id 8BED52092B; Thu, 21 Jun 2018 11:03:11 +0200 (CEST) Message-ID: Subject: Re: [PATCH 2/9] media: cedrus: Add wrappers around container_of for our buffers From: Paul Kocialkowski To: Maxime Ripard , hans.verkuil@cisco.com, acourbot@chromium.org, sakari.ailus@linux.intel.com, Laurent Pinchart Cc: tfiga@chromium.org, posciak@chromium.org, 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 Date: Thu, 21 Jun 2018 11:03:11 +0200 In-Reply-To: <20180613140714.1686-3-maxime.ripard@bootlin.com> References: <20180613140714.1686-1-maxime.ripard@bootlin.com> <20180613140714.1686-3-maxime.ripard@bootlin.com> Organization: Bootlin Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-XkHNW+2PPnHf+ivRpA0m" X-Mailer: Evolution 3.28.2 Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-XkHNW+2PPnHf+ivRpA0m Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, On Wed, 2018-06-13 at 16:07 +0200, Maxime Ripard wrote: > 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 nee= ds > to be duplicated in every calling site. >=20 > Add wrappers to make sure its opaque to the users and they don't have to > care anymore. >=20 > 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(-) >=20 > 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; > }; > =20 > +static inline I'm not a big fan of spreading the type qualifiers on two distinct lines instead of having a longer single line (reminds me of the GNU coding style a bit), but this is purely cosmetic. Cheers, Paul > +struct sunxi_cedrus_buffer *vb2_v4l2_to_cedrus_buffer(const struct vb2_v= 4l2_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/driv= ers/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; > } > =20 > - src_buffer =3D container_of(src_vb, struct sunxi_cedrus_buffer, vb); > - dst_buffer =3D container_of(dst_vb, struct sunxi_cedrus_buffer, vb); > + src_buffer =3D vb2_v4l2_to_cedrus_buffer(src_vb); > + dst_buffer =3D vb2_v4l2_to_cedrus_buffer(dst_vb); > =20 > /* First bit of MPEG_STATUS indicates success. */ > if (ctx->job_abort || !(status & 0x01)) --=20 Paul Kocialkowski, Bootlin (formerly Free Electrons) Embedded Linux and kernel engineering https://bootlin.com --=-XkHNW+2PPnHf+ivRpA0m Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJZpWjZeIetVBefti3cLmz3+fv9EFAlsrac8ACgkQ3cLmz3+f v9HFmgf/aIXwnztdvw5bePsyuoGb2CAA4h3dfo9ddQ2AcDtVU7baPUW1OgLeFsEx SgS4i/a7/jPUtcugrYNfCXQNk1AiWg6Z0PJCk33SXUpID2u+4zdNn29t5yOWu29O OHi0u1s0wgBlq/hXH1hlGDKSe/V4WFNBlLjZj61oxhDh2AHrLo6lo4DO9wKQ2BaI +ZZEeooLBvH/zfaaWXI24npAKecdvSwfq+89JH4XqN87EFzq5ORq1/1GhD0V6AWs p8gkAETBtALc955mu/qWmwZXeez4uruqGrpeu6eLUhR71pog12VtzxxGqNTynq3u YoT+++HN4BlW6vDX1OA3LJE9R6pGSw== =38y6 -----END PGP SIGNATURE----- --=-XkHNW+2PPnHf+ivRpA0m--