All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 09/10] drm/nv50/evo: store iomem pointer in properly typed field
@ 2012-08-19 21:00 Marcin Slusarz
       [not found] ` <1345410004-27729-9-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Marcin Slusarz @ 2012-08-19 21:00 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Abuse of function pointer was noticed by sparse.

Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/gpu/drm/nouveau/nv50_evo.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nv50_evo.c b/drivers/gpu/drm/nouveau/nv50_evo.c
index 0f53416..0483cbd 100644
--- a/drivers/gpu/drm/nouveau/nv50_evo.c
+++ b/drivers/gpu/drm/nouveau/nv50_evo.c
@@ -33,17 +33,22 @@
 #include <subdev/timer.h>
 #include <subdev/fb.h>
 
+struct evo_object {
+	struct nouveau_object parent;
+	void __iomem *iomem;
+};
+
 static u32
 nv50_evo_rd32(struct nouveau_object *object, u32 addr)
 {
-	void __iomem *iomem = object->oclass->ofuncs->rd08;
+	void __iomem *iomem = ((struct evo_object *)object)->iomem;
 	return ioread32_native(iomem + addr);
 }
 
 static void
 nv50_evo_wr32(struct nouveau_object *object, u32 addr, u32 data)
 {
-	void __iomem *iomem = object->oclass->ofuncs->rd08;
+	void __iomem *iomem = ((struct evo_object *)object)->iomem;
 	iowrite32_native(data, iomem + addr);
 }
 
@@ -60,7 +65,7 @@ nv50_evo_channel_del(struct nouveau_channel **pevo)
 	nouveau_bo_ref(NULL, &evo->push.buffer);
 
 	if (evo->object)
-		iounmap(evo->object->oclass->ofuncs);
+		iounmap(((struct evo_object *)evo->object)->iomem);
 
 	kfree(evo);
 }
@@ -112,6 +117,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
 	struct nouveau_drm *drm = nouveau_drm(dev);
 	struct nv50_display *disp = nv50_display(dev);
 	struct nouveau_channel *evo;
+	struct evo_object *evo_object;
 	int ret;
 
 	evo = kzalloc(sizeof(struct nouveau_channel), GFP_KERNEL);
@@ -142,7 +148,8 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
 		return ret;
 	}
 
-	evo->object = kzalloc(sizeof(*evo->object), GFP_KERNEL);
+	evo_object = kzalloc(sizeof(*evo_object), GFP_KERNEL);
+	evo->object = &evo_object->parent;
 #ifdef NOUVEAU_OBJECT_MAGIC
 	evo->object->_magic = NOUVEAU_OBJECT_MAGIC;
 #endif
@@ -154,8 +161,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
 		kzalloc(sizeof(*evo->object->oclass->ofuncs), GFP_KERNEL);
 	evo->object->oclass->ofuncs->rd32 = nv50_evo_rd32;
 	evo->object->oclass->ofuncs->wr32 = nv50_evo_wr32;
-	evo->object->oclass->ofuncs->rd08 =
-		ioremap(pci_resource_start(dev->pdev, 0) +
+	evo_object->iomem = ioremap(pci_resource_start(dev->pdev, 0) +
 			NV50_PDISPLAY_USER(evo->handle), PAGE_SIZE);
 	return 0;
 }
-- 
1.7.8.6

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

* Re: [PATCH 09/10] drm/nv50/evo: store iomem pointer in properly typed field
       [not found] ` <1345410004-27729-9-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-08-20  6:32   ` Ben Skeggs
       [not found]     ` <20120820063211.GE2013-7ZJhIA9XobAf7BdofF/totBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Skeggs @ 2012-08-20  6:32 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Sun, Aug 19, 2012 at 11:00:04PM +0200, Marcin Slusarz wrote:
> Abuse of function pointer was noticed by sparse.
I'm aware of this horror, however I didn't apply the patch.  I have work in
progress that'll get rid of this nasty stuff before the tree goes upstream,
doing it this way was a quick hack to keep things working and be able to
push the tree until it's ready.

> 
> Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/gpu/drm/nouveau/nv50_evo.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nv50_evo.c b/drivers/gpu/drm/nouveau/nv50_evo.c
> index 0f53416..0483cbd 100644
> --- a/drivers/gpu/drm/nouveau/nv50_evo.c
> +++ b/drivers/gpu/drm/nouveau/nv50_evo.c
> @@ -33,17 +33,22 @@
>  #include <subdev/timer.h>
>  #include <subdev/fb.h>
>  
> +struct evo_object {
> +	struct nouveau_object parent;
> +	void __iomem *iomem;
> +};
> +
>  static u32
>  nv50_evo_rd32(struct nouveau_object *object, u32 addr)
>  {
> -	void __iomem *iomem = object->oclass->ofuncs->rd08;
> +	void __iomem *iomem = ((struct evo_object *)object)->iomem;
>  	return ioread32_native(iomem + addr);
>  }
>  
>  static void
>  nv50_evo_wr32(struct nouveau_object *object, u32 addr, u32 data)
>  {
> -	void __iomem *iomem = object->oclass->ofuncs->rd08;
> +	void __iomem *iomem = ((struct evo_object *)object)->iomem;
>  	iowrite32_native(data, iomem + addr);
>  }
>  
> @@ -60,7 +65,7 @@ nv50_evo_channel_del(struct nouveau_channel **pevo)
>  	nouveau_bo_ref(NULL, &evo->push.buffer);
>  
>  	if (evo->object)
> -		iounmap(evo->object->oclass->ofuncs);
> +		iounmap(((struct evo_object *)evo->object)->iomem);
>  
>  	kfree(evo);
>  }
> @@ -112,6 +117,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
>  	struct nouveau_drm *drm = nouveau_drm(dev);
>  	struct nv50_display *disp = nv50_display(dev);
>  	struct nouveau_channel *evo;
> +	struct evo_object *evo_object;
>  	int ret;
>  
>  	evo = kzalloc(sizeof(struct nouveau_channel), GFP_KERNEL);
> @@ -142,7 +148,8 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
>  		return ret;
>  	}
>  
> -	evo->object = kzalloc(sizeof(*evo->object), GFP_KERNEL);
> +	evo_object = kzalloc(sizeof(*evo_object), GFP_KERNEL);
> +	evo->object = &evo_object->parent;
>  #ifdef NOUVEAU_OBJECT_MAGIC
>  	evo->object->_magic = NOUVEAU_OBJECT_MAGIC;
>  #endif
> @@ -154,8 +161,7 @@ nv50_evo_channel_new(struct drm_device *dev, int chid,
>  		kzalloc(sizeof(*evo->object->oclass->ofuncs), GFP_KERNEL);
>  	evo->object->oclass->ofuncs->rd32 = nv50_evo_rd32;
>  	evo->object->oclass->ofuncs->wr32 = nv50_evo_wr32;
> -	evo->object->oclass->ofuncs->rd08 =
> -		ioremap(pci_resource_start(dev->pdev, 0) +
> +	evo_object->iomem = ioremap(pci_resource_start(dev->pdev, 0) +
>  			NV50_PDISPLAY_USER(evo->handle), PAGE_SIZE);
>  	return 0;
>  }
> -- 
> 1.7.8.6
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau

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

* Re: [PATCH 09/10] drm/nv50/evo: store iomem pointer in properly typed field
       [not found]     ` <20120820063211.GE2013-7ZJhIA9XobAf7BdofF/totBPR1lH4CV8@public.gmane.org>
@ 2012-10-04 11:34       ` Marcin Slusarz
  0 siblings, 0 replies; 3+ messages in thread
From: Marcin Slusarz @ 2012-10-04 11:34 UTC (permalink / raw)
  To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Mon, Aug 20, 2012 at 04:32:11PM +1000, Ben Skeggs wrote:
> On Sun, Aug 19, 2012 at 11:00:04PM +0200, Marcin Slusarz wrote:
> > Abuse of function pointer was noticed by sparse.
> I'm aware of this horror, however I didn't apply the patch.  I have work in
> progress that'll get rid of this nasty stuff before the tree goes upstream,

*cough*

This patch is still applicable and the tree went upstream...

> doing it this way was a quick hack to keep things working and be able to
> push the tree until it's ready.

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

end of thread, other threads:[~2012-10-04 11:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-19 21:00 [PATCH 09/10] drm/nv50/evo: store iomem pointer in properly typed field Marcin Slusarz
     [not found] ` <1345410004-27729-9-git-send-email-marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-08-20  6:32   ` Ben Skeggs
     [not found]     ` <20120820063211.GE2013-7ZJhIA9XobAf7BdofF/totBPR1lH4CV8@public.gmane.org>
2012-10-04 11:34       ` Marcin Slusarz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.