[PATCH 2/9 linux-next] drm/mgag200: use container_of to resolve mga_fbdev from drm_fb_helper

Fabian Frederick fabf at skynet.be
Sun Sep 14 09:40:15 PDT 2014


Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf at skynet.be>
---
Compiled but untested.

 drivers/gpu/drm/mgag200/mgag200_fb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
index 5451dc5..4415af3 100644
--- a/drivers/gpu/drm/mgag200/mgag200_fb.c
+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
@@ -158,7 +158,8 @@ static int mgag200fb_create_object(struct mga_fbdev *afbdev,
 static int mgag200fb_create(struct drm_fb_helper *helper,
 			   struct drm_fb_helper_surface_size *sizes)
 {
-	struct mga_fbdev *mfbdev = (struct mga_fbdev *)helper;
+	struct mga_fbdev *mfbdev =
+		container_of(helper, struct mga_fbdev, helper);
 	struct drm_device *dev = mfbdev->helper.dev;
 	struct drm_mode_fb_cmd2 mode_cmd;
 	struct mga_device *mdev = dev->dev_private;
-- 
1.9.1



More information about the dri-devel mailing list