Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6611399rwr; Tue, 25 Apr 2023 00:41:56 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1z044h0wknDkv2rUlCbCkDpH0RftS24Focq8SyXKuuB2OhLvFdTn+KsmkOKhNHTIHhlIq X-Received: by 2002:a17:902:bb0f:b0:1a6:a375:cb49 with SMTP id im15-20020a170902bb0f00b001a6a375cb49mr14443398plb.39.1682408516306; Tue, 25 Apr 2023 00:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682408516; cv=none; d=google.com; s=arc-20160816; b=DYNJCzo+6B3zPKeNAIU/kBBrGbXswMegPdyeSa2zpX3bzDkl6ZZeeYA+Oy8EvFBDHq V7tRtkOVEjIWCaBFSiPHbWYZxk7BhMjOS+nOXDrQZmRMARKzY11q5A7jjjjl9zWpGfp3 +4qxCrBZTnevQCDtoDl4qplt2P6qOT90eTe5OI83ZsHo0o+2bpF29UAf6tg6jppaH7xf k/HsFIyzuilWCtqIVrOd7HKPOCdyNIMMRpMeeQoq8mKtqTqE49dFyr+ewbaN4glDrJvg UEer6KBeTfp9PmhBcI+QbeuZtkHtO3h6BnsoCJJGvZ07wYtY6aDP/0cpEDoL7Mpeo0J9 hh4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=RTqHKH5kW3d3hEeif41q3EZzXW9t1gA8K2PaRLkKVZg=; b=aNPNcBxs2gTJ+At7Vcb5l0uS7CRybS/MsexSqQ024YSbkg1JxygNvskDFsNN7Pjh1m yXHhUxzvJxmlVqKN/LmoaaWcj0n8nlz8WBIutcZbEvtysSeSL66U3kmzU0XO0SVUAm3k V8tLCxuMuz5X9N+Lbps8JHugp7g7imvshFvARpTW+PoVfHyNt7VvcJrHeO2gy+szedUY 97NBF4f7P6W6DGjoTH2s/18TS8HcIixyY+zNbPvTgdcDxlZ13vwNEwcHkoZ4Xv8WpGV+ t55FRcuZx7a+zBz8wCffaPsc25N2ZX5rymBSibNR2vXgucSrLSyYFPDFkz6JdLl8OmqT 513w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=qeofkEuO; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OvJEZhoJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a170902a40d00b001a52c82907bsi12599205plq.191.2023.04.25.00.41.44; Tue, 25 Apr 2023 00:41:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=qeofkEuO; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=OvJEZhoJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbjDYHkY (ORCPT + 99 others); Tue, 25 Apr 2023 03:40:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233353AbjDYHjm (ORCPT ); Tue, 25 Apr 2023 03:39:42 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A3B119B5 for ; Tue, 25 Apr 2023 00:38:55 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id DFF0B5C0088; Tue, 25 Apr 2023 03:38:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 25 Apr 2023 03:38:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1682408334; x=1682494734; bh=RT qHKH5kW3d3hEeif41q3EZzXW9t1gA8K2PaRLkKVZg=; b=qeofkEuO9/Lijbwef4 uY0IEaM6DwlkO3Gjogc1XCCRHNnBNaAbY/PBP4fXl63ugTBmN05g/sOYVwQTis4f SgfcRU2JNUNFZ7wmb2DUtngLpxjNYJ/0VxRIJvNR0hPNaZgpm40X/CCu+yd40nDJ NCLHIdIYKlMtZ/QjpLzXf/Ht9UuY9A9xQ5UFL2/2uSpsk3i/hh9ieowEVmZXiu/Y BPLKL4iEW1v5tOSwQp14qkxrvDE04Xm4OlLG4j7+M9pg2XEgW+lDEP90vdbpdmJf Lecdb+P4xof/nk+JTVdPJ96tOvA2yBu9taYYlVsIyOJh3GgnF+F80YqM5zQ4D9YC T4+w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1682408334; x=1682494734; bh=RTqHKH5kW3d3h Eeif41q3EZzXW9t1gA8K2PaRLkKVZg=; b=OvJEZhoJesRORA74KJ6VAW0UdoCi+ n8vtYGFRZ4cFg4qyD4udh4TW2VvgyoB6iBFKJ8606vGiW6aMdlZebXCKQtUGkKJt gb4YnBfeIiNLJeaSOjH0EWyGbKWe0RqBnR9McJyqX4G4xUhPsfuqifx0dPl/nzZ6 VysFHevGRtTPT1ZGzwusvdpUsRakmK+sEfUOZ+6Je6IRNISPfJepEJliqqF3LBOW vHCuMY58QXEyy4EKMR/MxVlH7Pgj5O8puQB+HsVm7Bjuduz3MI5u482gI+yIJB/k j+DlicL6ZDhp3Ej/Ty994MeOy/uSOIkF1HoGWszrWccZ36HT/+xJUdOFw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeduuddguddvfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtdfsredttddvnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepueevudehuedtkeevgfduveejueefvddvvefhjefglefgtdekveeugeet kefgleefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Apr 2023 03:38:54 -0400 (EDT) Date: Tue, 25 Apr 2023 09:38:52 +0200 From: Maxime Ripard To: Javier Martinez Canillas Cc: Emma Anholt , David Airlie , Daniel Vetter , Hans Verkuil , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Subject: Re: [PATCH v3 1/9] drm/vc4: Switch to container_of_const Message-ID: <6ckl6zmizxsm52imeau55bicb4hmd3p46btsqih64qaoeptvww@bktsqhuq4lek> References: <20221207-rpi-hdmi-improvements-v3-0-bdd54f66884e@cerno.tech> <20221207-rpi-hdmi-improvements-v3-1-bdd54f66884e@cerno.tech> <87354sij2i.fsf@minerva.mail-host-address-is-not-set> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jsmbnufzclhulggs" Content-Disposition: inline In-Reply-To: <87354sij2i.fsf@minerva.mail-host-address-is-not-set> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --jsmbnufzclhulggs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Javier, On Sat, Apr 22, 2023 at 07:26:13AM +0200, Javier Martinez Canillas wrote: > Maxime Ripard writes: > > container_of_const() allows to preserve the pointer constness and is > > thus more flexible than inline functions. > > > > Let's switch all our instances of container_of() to > > container_of_const(). > > > > Signed-off-by: Maxime Ripard > > --- >=20 > [...] >=20 > > -static inline struct vc4_dpi * > > -to_vc4_dpi(struct drm_encoder *encoder) > > -{ > > - return container_of(encoder, struct vc4_dpi, encoder.base); > > -} > > +#define to_vc4_dpi(_encoder) \ > > + container_of_const(_encoder, struct vc4_dpi, encoder.base) > > >=20 > A disadvantage of this approach though is that the type checking is lost. Not entirely, the argument is still type-checked, but yeah, it's true for the returned value. > Since you already had these, I would probably had changed them to return > a const pointer and just replace container_of() for container_of_const(). >=20 > But I see that there are a lot of patches from Greg all over the kernel > that do exactly this, dropping static inline functions in favor of using > container_of_const() directly. So it seems the convention is what you do. More importantly, container_of_const() isn't always returning a const pointer or always taking a const argument, it's returning the pointer with the same const-ness than the argument. This is why it makes sense to remove the inline function entirely, because it removes the main benefit it brings. > Reviewed-by: Javier Martinez Canillas Thanks, I've applied this series Maxime --jsmbnufzclhulggs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZEeDjAAKCRDj7w1vZxhR xWKJAP9i+arWN3T/cwrP5SbdIhY2zgDcWVyy/DWNXipJSFCEpQEAu5/219HTRpQn eeMJY41X7MyUhwOYkK3GWkkMJjBcHQE= =MpDn -----END PGP SIGNATURE----- --jsmbnufzclhulggs--