From: Javier Martinez Canillas <javierm@redhat.com>
To: Maxime Ripard <maxime@cerno.tech>, Emma Anholt <emma@anholt.net>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Maxime Ripard <maxime@cerno.tech>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/9] drm/vc4: Switch to container_of_const
Date: Sat, 22 Apr 2023 07:26:13 +0200 [thread overview]
Message-ID: <87354sij2i.fsf@minerva.mail-host-address-is-not-set> (raw)
In-Reply-To: <20221207-rpi-hdmi-improvements-v3-1-bdd54f66884e@cerno.tech>
Maxime Ripard <maxime@cerno.tech> writes:
Hello Maxime,
> 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.
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.
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
next prev parent reply other threads:[~2023-04-22 5:26 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 [this message]
2023-04-25 7:38 ` Maxime Ripard
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=87354sij2i.fsf@minerva.mail-host-address-is-not-set \
--to=javierm@redhat.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dave.stevenson@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emma@anholt.net \
--cc=hverkuil@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime@cerno.tech \
--cc=mripard@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).