From: Maxime Ripard <maxime@cerno.tech>
To: Javier Martinez Canillas <javierm@redhat.com>
Cc: Emma Anholt <emma@anholt.net>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH v3 1/9] drm/vc4: Switch to container_of_const
Date: Tue, 25 Apr 2023 09:38:52 +0200 [thread overview]
Message-ID: <6ckl6zmizxsm52imeau55bicb4hmd3p46btsqih64qaoeptvww@bktsqhuq4lek> (raw)
In-Reply-To: <87354sij2i.fsf@minerva.mail-host-address-is-not-set>
[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]
Hi Javier,
On Sat, Apr 22, 2023 at 07:26:13AM +0200, Javier Martinez Canillas wrote:
> Maxime Ripard <maxime@cerno.tech> 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 <maxime@cerno.tech>
> > ---
>
> [...]
>
> > -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)
> >
>
> 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().
>
> 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 <javierm@redhat.com>
Thanks, I've applied this series
Maxime
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-04-25 7:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 10:46 [PATCH v3 0/9] drm/vc4: hdmi: Broadcast RGB, BT601, BT2020 Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 1/9] drm/vc4: Switch to container_of_const Maxime Ripard
2023-04-22 5:26 ` Javier Martinez Canillas
2023-04-25 7:38 ` Maxime Ripard [this message]
2023-04-25 8:21 ` Javier Martinez Canillas
2023-03-06 10:46 ` [PATCH v3 2/9] drm/vc4: hdmi: Update all the planes if the TV margins are changed Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 3/9] drm/vc4: hdmi: Add Broadcast RGB property to allow override of RGB range Maxime Ripard
2023-10-11 13:23 ` Daniel Vetter
2023-10-19 8:02 ` Maxime Ripard
2023-10-19 8:26 ` Hans Verkuil
2023-10-23 14:58 ` Maxime Ripard
2023-10-23 16:22 ` Sebastian Wick
2023-03-06 10:46 ` [PATCH v3 4/9] drm/vc4: hdmi: Rename full range helper Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 5/9] drm/vc4: hdmi: Swap CSC matrix channels for YUV444 Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 6/9] drm/vc4: hdmi: Rework the CSC matrices organization Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 7/9] drm/vc4: hdmi: Add a function to retrieve the CSC matrix Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 8/9] drm/vc4: hdmi: Add BT.601 Support Maxime Ripard
2023-03-06 10:46 ` [PATCH v3 9/9] drm/vc4: hdmi: Add BT.2020 Support Maxime Ripard
2023-04-25 7:34 ` [PATCH v3 0/9] drm/vc4: hdmi: Broadcast RGB, BT601, BT2020 Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6ckl6zmizxsm52imeau55bicb4hmd3p46btsqih64qaoeptvww@bktsqhuq4lek \
--to=maxime@cerno.tech \
--cc=dave.stevenson@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=hverkuil@xs4all.nl \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).