From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Noralf Trønnes" <noralf@tronnes.org>
Cc: daniel.vetter@ffwll.ch, tomi.valkeinen@ti.com,
hoegsberg@gmail.com, abrodkin@synopsys.com,
dri-devel@lists.freedesktop.org, liviu.dudau@arm.com,
jsarha@ti.com
Subject: Re: [PATCH v5 06/12] drm/cma-helper: Turn to_drm_gem_cma_obj() into a macro
Date: Wed, 08 Nov 2017 08:21:42 +0200 [thread overview]
Message-ID: <1547526.iHoqOuSPNE@avalon> (raw)
In-Reply-To: <20171107191348.17555-7-noralf@tronnes.org>
Hi Noralf,
Thank you for the patch.
On Tuesday, 7 November 2017 21:13:42 EET Noralf Trønnes wrote:
> This allows the argument to be a const.
>
> The other option was to keep it an inline function and make the argument
> a const:
>
> static inline struct drm_gem_cma_object *
> to_drm_gem_cma_obj(const struct drm_gem_object *gem_obj)
> {
> return container_of(gem_obj, struct drm_gem_cma_object, base);
> }
>
> This will happily return a non-const pointer to the drm_gem_cma_object
> based on a const pointer to the contained drm_gem_object, thus creating
> const-safety problems.
>
> There was an attempt to fix the problem in the container_of() macro
> itself (see https://lkml.org/lkml/2017/5/19/381) but the patch seems to
> have fallen through the cracks. It would require turning this inline
> function into a macro.
>
> By making this a macro now, we will benefit from a possible future
> enhancement of container_of(). We don't loose type checking by doing
> this, container_of() takes care of that.
>
> Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> include/drm/drm_gem_cma_helper.h | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/include/drm/drm_gem_cma_helper.h
> b/include/drm/drm_gem_cma_helper.h index 58a739bf15f1..7a3dcf0cf289 100644
> --- a/include/drm/drm_gem_cma_helper.h
> +++ b/include/drm/drm_gem_cma_helper.h
> @@ -20,11 +20,8 @@ struct drm_gem_cma_object {
> void *vaddr;
> };
>
> -static inline struct drm_gem_cma_object *
> -to_drm_gem_cma_obj(struct drm_gem_object *gem_obj)
> -{
> - return container_of(gem_obj, struct drm_gem_cma_object, base);
> -}
> +#define to_drm_gem_cma_obj(gem_obj) \
> + container_of(gem_obj, struct drm_gem_cma_object, base)
>
> #ifndef CONFIG_MMU
> #define DRM_GEM_CMA_UNMAPPED_AREA_FOPS \
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-11-08 6:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 19:13 [PATCH v5 00/12] drm/framebuffer: Add framebuffer debugfs file Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 01/12] drm/vma-manager: drm_vma_node_start() constify argument Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 02/12] drm/framebuffer: drm_framebuffer_read_refcount() " Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 03/12] drm/print: Add drm_printf_indent() Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 04/12] drm/framebuffer: Add framebuffer debugfs file Noralf Trønnes
2017-11-11 18:55 ` Chris Wilson
2017-11-13 19:54 ` Noralf Trønnes
2017-11-13 21:33 ` Chris Wilson
2017-11-13 22:12 ` Noralf Trønnes
2017-11-13 22:17 ` Chris Wilson
2017-11-13 22:31 ` Noralf Trønnes
2017-11-20 7:38 ` Daniel Vetter
2017-11-07 19:13 ` [PATCH v5 05/12] drm/atomic: Use drm_framebuffer_print_info() Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 06/12] drm/cma-helper: Turn to_drm_gem_cma_obj() into a macro Noralf Trønnes
2017-11-08 6:21 ` Laurent Pinchart [this message]
2017-11-07 19:13 ` [PATCH v5 07/12] drm/cma-helper: Add drm_gem_cma_print_info() Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 08/12] drm/arc: Use drm_gem_cma_print_info() Noralf Trønnes
2017-11-07 19:31 ` Alexey Brodkin
2017-11-09 15:52 ` Noralf Trønnes
2017-11-09 16:44 ` Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 09/12] drm/arm/hdlcd: " Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 10/12] drm/tilcdc: " Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 11/12] drm/tinydrm: " Noralf Trønnes
2017-11-07 19:13 ` [PATCH v5 12/12] drm/cma-helper: Remove drm_fb_cma_debugfs_show() Noralf Trønnes
2017-11-11 10:37 ` [PATCH v5 00/12] drm/framebuffer: Add framebuffer debugfs file Noralf Trønnes
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=1547526.iHoqOuSPNE@avalon \
--to=laurent.pinchart@ideasonboard.com \
--cc=abrodkin@synopsys.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=hoegsberg@gmail.com \
--cc=jsarha@ti.com \
--cc=liviu.dudau@arm.com \
--cc=noralf@tronnes.org \
--cc=tomi.valkeinen@ti.com \
/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