linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible
@ 2014-09-14 16:40 Fabian Frederick
  2014-09-14 16:40 ` [PATCH 1/9 linux-next] drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper Fabian Frederick
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Small patchset using container_of instead of casting on first structure member address.

Fabian Frederick (9):
  drm/cirrus: use container_of to resolve cirrus_fbdev from
    drm_fb_helper
  drm/mgag200: use container_of to resolve mga_fbdev from drm_fb_helper
  drm/radeon: use container_of to resolve radeon_fbdev from
    drm_fb_helper
  drm/nouveau: use container_of to resolve nouveau_fbdev from
    drm_fb_helper
  drm/nouveau: use container_of to resolve nouveau_plane from drm_plane
  drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper
  drm/gma500: use container_of to resolve psb_fbdev from drm_fb_helper
  drm/ast: use container_of to resolve ast_fbdev from drm_fb_helper
  drm/udl: use container_of to resolve udl_fbdev from drm_fb_helper

 drivers/gpu/drm/ast/ast_fb.c               |  3 ++-
 drivers/gpu/drm/cirrus/cirrus_fbdev.c      |  3 ++-
 drivers/gpu/drm/gma500/framebuffer.c       |  3 ++-
 drivers/gpu/drm/mgag200/mgag200_fb.c       |  3 ++-
 drivers/gpu/drm/nouveau/dispnv04/overlay.c | 15 ++++++++++-----
 drivers/gpu/drm/nouveau/nouveau_fbcon.c    |  3 ++-
 drivers/gpu/drm/qxl/qxl_fb.c               |  3 ++-
 drivers/gpu/drm/radeon/radeon_fb.c         |  3 ++-
 drivers/gpu/drm/udl/udl_fb.c               |  3 ++-
 9 files changed, 26 insertions(+), 13 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/9 linux-next] drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 2/9 linux-next] drm/mgag200: use container_of to resolve mga_fbdev " Fabian Frederick
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
index 2a135f2..d231b1c 100644
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
@@ -160,7 +160,8 @@ static int cirrusfb_create_object(struct cirrus_fbdev *afbdev,
 static int cirrusfb_create(struct drm_fb_helper *helper,
 			   struct drm_fb_helper_surface_size *sizes)
 {
-	struct cirrus_fbdev *gfbdev = (struct cirrus_fbdev *)helper;
+	struct cirrus_fbdev *gfbdev =
+		container_of(helper, struct cirrus_fbdev, helper);
 	struct drm_device *dev = gfbdev->helper.dev;
 	struct cirrus_device *cdev = gfbdev->helper.dev->dev_private;
 	struct fb_info *info;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/9 linux-next] drm/mgag200: use container_of to resolve mga_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
  2014-09-14 16:40 ` [PATCH 1/9 linux-next] drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 3/9 linux-next] drm/radeon: use container_of to resolve radeon_fbdev " Fabian Frederick
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

Signed-off-by: Fabian Frederick <fabf@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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/9 linux-next] drm/radeon: use container_of to resolve radeon_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
  2014-09-14 16:40 ` [PATCH 1/9 linux-next] drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper Fabian Frederick
  2014-09-14 16:40 ` [PATCH 2/9 linux-next] drm/mgag200: use container_of to resolve mga_fbdev " Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 4/9 linux-next] drm/nouveau: use container_of to resolve nouveau_fbdev " Fabian Frederick
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel
  Cc: airlied, Fabian Frederick, Alex Deucher, Christian König, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 94b0f2a..0ea1db8 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -189,7 +189,8 @@ out_unref:
 static int radeonfb_create(struct drm_fb_helper *helper,
 			   struct drm_fb_helper_surface_size *sizes)
 {
-	struct radeon_fbdev *rfbdev = (struct radeon_fbdev *)helper;
+	struct radeon_fbdev *rfbdev =
+		container_of(helper, struct radeon_fbdev, helper);
 	struct radeon_device *rdev = rfbdev->rdev;
 	struct fb_info *info;
 	struct drm_framebuffer *fb = NULL;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/9 linux-next] drm/nouveau: use container_of to resolve nouveau_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (2 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 3/9 linux-next] drm/radeon: use container_of to resolve radeon_fbdev " Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 5/9 linux-next] drm/nouveau: use container_of to resolve nouveau_plane from drm_plane Fabian Frederick
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 8bdd270..673d270 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -308,7 +308,8 @@ static int
 nouveau_fbcon_create(struct drm_fb_helper *helper,
 		     struct drm_fb_helper_surface_size *sizes)
 {
-	struct nouveau_fbdev *fbcon = (struct nouveau_fbdev *)helper;
+	struct nouveau_fbdev *fbcon =
+		container_of(helper, struct nouveau_fbdev, helper);
 	struct drm_device *dev = fbcon->dev;
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nvif_device *device = &drm->device;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/9 linux-next] drm/nouveau: use container_of to resolve nouveau_plane from drm_plane
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (3 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 4/9 linux-next] drm/nouveau: use container_of to resolve nouveau_fbdev " Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 6/9 linux-next] drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper Fabian Frederick
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

 drivers/gpu/drm/nouveau/dispnv04/overlay.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index b36afcb..1e9056a 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -97,7 +97,8 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		  uint32_t src_w, uint32_t src_h)
 {
 	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
-	struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
+	struct nouveau_plane *nv_plane =
+		container_of(plane, struct nouveau_plane, base);
 	struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
 	struct nouveau_bo *cur = nv_plane->cur;
@@ -173,7 +174,8 @@ static int
 nv10_disable_plane(struct drm_plane *plane)
 {
 	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
-	struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
+	struct nouveau_plane *nv_plane =
+		container_of(plane, struct nouveau_plane, base);
 
 	nvif_wr32(dev, NV_PVIDEO_STOP, 1);
 	if (nv_plane->cur) {
@@ -224,7 +226,8 @@ nv_set_property(struct drm_plane *plane,
 		struct drm_property *property,
 		uint64_t value)
 {
-	struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
+	struct nouveau_plane *nv_plane =
+		container_of(plane, struct nouveau_plane, base);
 
 	if (property == nv_plane->props.colorkey)
 		nv_plane->colorkey = value;
@@ -344,7 +347,8 @@ nv04_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		  uint32_t src_w, uint32_t src_h)
 {
 	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
-	struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
+	struct nouveau_plane *nv_plane =
+		container_of(plane, struct nouveau_plane, base);
 	struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
 	struct nouveau_bo *cur = nv_plane->cur;
 	uint32_t overlay = 1;
@@ -423,7 +427,8 @@ static int
 nv04_disable_plane(struct drm_plane *plane)
 {
 	struct nvif_device *dev = &nouveau_drm(plane->dev)->device;
-	struct nouveau_plane *nv_plane = (struct nouveau_plane *)plane;
+	struct nouveau_plane *nv_plane =
+		container_of(plane, struct nouveau_plane, base);
 
 	nvif_mask(dev, NV_PVIDEO_OVERLAY, 1, 0);
 	nvif_wr32(dev, NV_PVIDEO_OE_STATE, 0);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/9 linux-next] drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (4 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 5/9 linux-next] drm/nouveau: use container_of to resolve nouveau_plane from drm_plane Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 7/9 linux-next] drm/gma500: use container_of to resolve psb_fbdev " Fabian Frederick
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index df56788..3d7c1d0 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -625,7 +625,8 @@ static int qxl_fb_find_or_create_single(
 		struct drm_fb_helper *helper,
 		struct drm_fb_helper_surface_size *sizes)
 {
-	struct qxl_fbdev *qfbdev = (struct qxl_fbdev *)helper;
+	struct qxl_fbdev *qfbdev =
+		container_of(helper, struct qxl_fbdev, helper);
 	int new_fb = 0;
 	int ret;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 7/9 linux-next] drm/gma500: use container_of to resolve psb_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (5 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 6/9 linux-next] drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 8/9 linux-next] drm/ast: use container_of to resolve ast_fbdev " Fabian Frederick
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index d0dd3be..ddd90dd 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -540,7 +540,8 @@ static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
 static int psbfb_probe(struct drm_fb_helper *helper,
 				struct drm_fb_helper_surface_size *sizes)
 {
-	struct psb_fbdev *psb_fbdev = (struct psb_fbdev *)helper;
+	struct psb_fbdev *psb_fbdev =
+		container_of(helper, struct psb_fbdev, psb_fb_helper);
 	struct drm_device *dev = psb_fbdev->psb_fb_helper.dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	int bytespp;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 8/9 linux-next] drm/ast: use container_of to resolve ast_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (6 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 7/9 linux-next] drm/gma500: use container_of to resolve psb_fbdev " Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 16:40 ` [PATCH 9/9 linux-next] drm/udl: use container_of to resolve udl_fbdev " Fabian Frederick
  2014-09-14 23:13 ` [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible One Thousand Gnomes
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
index cba45c7..5c60ae5 100644
--- a/drivers/gpu/drm/ast/ast_fb.c
+++ b/drivers/gpu/drm/ast/ast_fb.c
@@ -186,7 +186,8 @@ static int astfb_create_object(struct ast_fbdev *afbdev,
 static int astfb_create(struct drm_fb_helper *helper,
 			struct drm_fb_helper_surface_size *sizes)
 {
-	struct ast_fbdev *afbdev = (struct ast_fbdev *)helper;
+	struct ast_fbdev *afbdev =
+		container_of(helper, struct ast_fbdev, helper);
 	struct drm_device *dev = afbdev->helper.dev;
 	struct drm_mode_fb_cmd2 mode_cmd;
 	struct drm_framebuffer *fb;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 9/9 linux-next] drm/udl: use container_of to resolve udl_fbdev from drm_fb_helper
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (7 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 8/9 linux-next] drm/ast: use container_of to resolve ast_fbdev " Fabian Frederick
@ 2014-09-14 16:40 ` Fabian Frederick
  2014-09-14 23:13 ` [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible One Thousand Gnomes
  9 siblings, 0 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-14 16:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: airlied, Fabian Frederick, dri-devel

Use container_of instead of casting first structure member.

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

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

diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index d1da339..8cbcb45 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -472,7 +472,8 @@ udl_framebuffer_init(struct drm_device *dev,
 static int udlfb_create(struct drm_fb_helper *helper,
 			struct drm_fb_helper_surface_size *sizes)
 {
-	struct udl_fbdev *ufbdev = (struct udl_fbdev *)helper;
+	struct udl_fbdev *ufbdev =
+		container_of(helper, struct udl_fbdev, helper);
 	struct drm_device *dev = ufbdev->helper.dev;
 	struct fb_info *info;
 	struct device *device = dev->dev;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible
  2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
                   ` (8 preceding siblings ...)
  2014-09-14 16:40 ` [PATCH 9/9 linux-next] drm/udl: use container_of to resolve udl_fbdev " Fabian Frederick
@ 2014-09-14 23:13 ` One Thousand Gnomes
  2014-09-15 18:15   ` Fabian Frederick
  9 siblings, 1 reply; 14+ messages in thread
From: One Thousand Gnomes @ 2014-09-14 23:13 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, airlied, dri-devel

On Sun, 14 Sep 2014 18:40:13 +0200
Fabian Frederick <fabf@skynet.be> wrote:

> Small patchset using container_of instead of casting on first structure member address.

Why. Container_of is useful for random offsets but its just convoluting
and confusing code which is designed with the fields intentionally at the
start.

Alan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible
  2014-09-14 23:13 ` [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible One Thousand Gnomes
@ 2014-09-15 18:15   ` Fabian Frederick
  2014-09-17 10:01     ` Daniel Vetter
  2014-09-17 10:49     ` One Thousand Gnomes
  0 siblings, 2 replies; 14+ messages in thread
From: Fabian Frederick @ 2014-09-15 18:15 UTC (permalink / raw)
  To: One Thousand Gnomes; +Cc: linux-kernel, airlied, dri-devel, peter



> On 15 September 2014 at 01:13 One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
> wrote:
>
>
> On Sun, 14 Sep 2014 18:40:13 +0200
> Fabian Frederick <fabf@skynet.be> wrote:
>
> > Small patchset using container_of instead of casting on first structure
> > member address.
>
> Why. Container_of is useful for random offsets but its just convoluting
> and confusing code which is designed with the fields intentionally at the
> start.
>
> Alan

What if someone doesn't know about that intention one day and inserts
some field in the structure at the "wrong place" ?
This would need at least some comment in each declaration
but once again it's hard to control.One other way is to
commonly use container_of and get rid of every casting with
some semantic script.

Peter has been asking for container_of in the following:

http://marc.info/?l=linux-arm-kernel&m=140838705729653&w=2


struct uart_amba_port *uap = (struct uart_amba_port *)port

(port/uart_port is the first field in uart_amba_port though)

Regards,
Fabian

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible
  2014-09-15 18:15   ` Fabian Frederick
@ 2014-09-17 10:01     ` Daniel Vetter
  2014-09-17 10:49     ` One Thousand Gnomes
  1 sibling, 0 replies; 14+ messages in thread
From: Daniel Vetter @ 2014-09-17 10:01 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: One Thousand Gnomes, linux-kernel, dri-devel, peter

On Mon, Sep 15, 2014 at 08:15:54PM +0200, Fabian Frederick wrote:
> 
> 
> > On 15 September 2014 at 01:13 One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
> > wrote:
> >
> >
> > On Sun, 14 Sep 2014 18:40:13 +0200
> > Fabian Frederick <fabf@skynet.be> wrote:
> >
> > > Small patchset using container_of instead of casting on first structure
> > > member address.
> >
> > Why. Container_of is useful for random offsets but its just convoluting
> > and confusing code which is designed with the fields intentionally at the
> > start.
> >
> > Alan
> 
> What if someone doesn't know about that intention one day and inserts
> some field in the structure at the "wrong place" ?
> This would need at least some comment in each declaration
> but once again it's hard to control.One other way is to
> commonly use container_of and get rid of every casting with
> some semantic script.
> 
> Peter has been asking for container_of in the following:
> 
> http://marc.info/?l=linux-arm-kernel&m=140838705729653&w=2
> 
> 
> struct uart_amba_port *uap = (struct uart_amba_port *)port
> 
> (port/uart_port is the first field in uart_amba_port though)

fwiw I like this and I've picked it up into my topic/core-stuff branch. So
if driver writers don't outright nack this it'll all land in Dave's
drm-next (probably still for 3.18).
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible
  2014-09-15 18:15   ` Fabian Frederick
  2014-09-17 10:01     ` Daniel Vetter
@ 2014-09-17 10:49     ` One Thousand Gnomes
  1 sibling, 0 replies; 14+ messages in thread
From: One Thousand Gnomes @ 2014-09-17 10:49 UTC (permalink / raw)
  To: Fabian Frederick; +Cc: linux-kernel, airlied, dri-devel, peter

> What if someone doesn't know about that intention one day and inserts
> some field in the structure at the "wrong place" ?

Then we have code review. Also they are much more likely to simply change
the code elsewhere and break it. Nobody afaik ever got this wrong, while
the litany of other broken patches and bugs introduced into the same code
is lagre.

The goal of the kernel is not to be foolproof to developer incompetence -
that's a battle you can't win until you replace driver developers with
software systems.

Alan

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-09-17 10:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-14 16:40 [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible Fabian Frederick
2014-09-14 16:40 ` [PATCH 1/9 linux-next] drm/cirrus: use container_of to resolve cirrus_fbdev from drm_fb_helper Fabian Frederick
2014-09-14 16:40 ` [PATCH 2/9 linux-next] drm/mgag200: use container_of to resolve mga_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 3/9 linux-next] drm/radeon: use container_of to resolve radeon_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 4/9 linux-next] drm/nouveau: use container_of to resolve nouveau_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 5/9 linux-next] drm/nouveau: use container_of to resolve nouveau_plane from drm_plane Fabian Frederick
2014-09-14 16:40 ` [PATCH 6/9 linux-next] drm/qxl: use container_of to resolve qxl_fbdev from drm_fb_helper Fabian Frederick
2014-09-14 16:40 ` [PATCH 7/9 linux-next] drm/gma500: use container_of to resolve psb_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 8/9 linux-next] drm/ast: use container_of to resolve ast_fbdev " Fabian Frederick
2014-09-14 16:40 ` [PATCH 9/9 linux-next] drm/udl: use container_of to resolve udl_fbdev " Fabian Frederick
2014-09-14 23:13 ` [PATCH 0/9 linux-next] drivers/gpu/drm: use container_of where possible One Thousand Gnomes
2014-09-15 18:15   ` Fabian Frederick
2014-09-17 10:01     ` Daniel Vetter
2014-09-17 10:49     ` One Thousand Gnomes

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).