[18/32] drm: Populate fb->dev from drm_helper_mode_fill_fb_struct()
diff mbox

Message ID 1479399271-31991-19-git-send-email-ville.syrjala@linux.intel.com
State New
Headers show

Commit Message

Ville Syrjälä Nov. 17, 2016, 4:14 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Populating fb->dev before drm_framebuffer_init() allows us to use
fb->dev already while validating the framebuffer. Let's have
drm_helper_mode_fill_fb_struct() do that for us.

Also make drm_framebuffer_init() warn us if a different device
pointer is passed to it than was passed to
drm_helper_mode_fill_fb_struct().

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_framebuffer.c    | 3 ++-
 drivers/gpu/drm/drm_modeset_helper.c | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Nov. 17, 2016, 5:43 p.m. UTC | #1
Hi Ville,

Thank you for the patch.

On Thursday 17 Nov 2016 18:14:17 ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Populating fb->dev before drm_framebuffer_init() allows us to use
> fb->dev already while validating the framebuffer. Let's have
> drm_helper_mode_fill_fb_struct() do that for us.
> 
> Also make drm_framebuffer_init() warn us if a different device
> pointer is passed to it than was passed to
> drm_helper_mode_fill_fb_struct().
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/gpu/drm/drm_framebuffer.c    | 3 ++-
>  drivers/gpu/drm/drm_modeset_helper.c | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_framebuffer.c
> b/drivers/gpu/drm/drm_framebuffer.c index cbf0c893f426..527220c08f9b 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -632,7 +632,8 @@ int drm_framebuffer_init(struct drm_device *dev, struct
> drm_framebuffer *fb, int ret;
> 
>  	INIT_LIST_HEAD(&fb->filp_head);
> -	fb->dev = dev;
> +	if (WARN_ON_ONCE(fb->dev != dev))
> +		fb->dev = dev;
>  	fb->funcs = funcs;
> 
>  	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c
> b/drivers/gpu/drm/drm_modeset_helper.c index 285ffcba0fe8..57a319e3f780
> 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -90,6 +90,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device
> *dev, fb->bits_per_pixel = info->cpp[0] * 8;
>  	}
> 
> +	fb->dev = dev;
>  	fb->width = mode_cmd->width;
>  	fb->height = mode_cmd->height;
>  	for (i = 0; i < 4; i++) {

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index cbf0c893f426..527220c08f9b 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -632,7 +632,8 @@  int drm_framebuffer_init(struct drm_device *dev, struct drm_framebuffer *fb,
 	int ret;
 
 	INIT_LIST_HEAD(&fb->filp_head);
-	fb->dev = dev;
+	if (WARN_ON_ONCE(fb->dev != dev))
+		fb->dev = dev;
 	fb->funcs = funcs;
 
 	ret = drm_mode_object_get_reg(dev, &fb->base, DRM_MODE_OBJECT_FB,
diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
index 285ffcba0fe8..57a319e3f780 100644
--- a/drivers/gpu/drm/drm_modeset_helper.c
+++ b/drivers/gpu/drm/drm_modeset_helper.c
@@ -90,6 +90,7 @@  void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
 		fb->bits_per_pixel = info->cpp[0] * 8;
 	}
 
+	fb->dev = dev;
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	for (i = 0; i < 4; i++) {