drm: i810_dma.c: fix pointer arithmetic for 64-bit target
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 16 Aug 2006 01:54:07 +0000 (11:54 +1000)
committerDave Airlie <airlied@linux.ie>
Thu, 21 Sep 2006 19:32:33 +0000 (05:32 +1000)
First warning result from open-coded PTR_ERR,
the rest is caused by code like this:

*(u32 *) ((u32) buf_priv->kernel_virtual + used)

I've also fixed a missing PTR_ERR in i830_dma.c

Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/i810_dma.c
drivers/char/drm/i830_dma.c

index 28ee6e3f1d99d3a55c60ed0686e9b3f82a7920cb..fa2de70f7401aded1c300fec6ba4799075348562 100644 (file)
@@ -141,10 +141,10 @@ static int i810_map_buffer(drm_buf_t * buf, struct file *filp)
                                            MAP_SHARED, buf->bus_address);
        dev_priv->mmap_buffer = NULL;
        filp->f_op = old_fops;
                                            MAP_SHARED, buf->bus_address);
        dev_priv->mmap_buffer = NULL;
        filp->f_op = old_fops;
-       if ((unsigned long)buf_priv->virtual > -1024UL) {
+       if (IS_ERR(buf_priv->virtual)) {
                /* Real error */
                DRM_ERROR("mmap error\n");
                /* Real error */
                DRM_ERROR("mmap error\n");
-               retcode = (signed int)buf_priv->virtual;
+               retcode = PTR_ERR(buf_priv->virtual);
                buf_priv->virtual = NULL;
        }
        up_write(&current->mm->mmap_sem);
                buf_priv->virtual = NULL;
        }
        up_write(&current->mm->mmap_sem);
@@ -808,7 +808,7 @@ static void i810_dma_dispatch_vertex(drm_device_t * dev,
                    ((GFX_OP_PRIMITIVE | prim | ((used / 4) - 2)));
 
                if (used & 4) {
                    ((GFX_OP_PRIMITIVE | prim | ((used / 4) - 2)));
 
                if (used & 4) {
-                       *(u32 *) ((u32) buf_priv->kernel_virtual + used) = 0;
+                       *(u32 *) ((char *) buf_priv->kernel_virtual + used) = 0;
                        used += 4;
                }
 
                        used += 4;
                }
 
@@ -1166,7 +1166,7 @@ static void i810_dma_dispatch_mc(drm_device_t * dev, drm_buf_t * buf, int used,
 
        if (buf_priv->currently_mapped == I810_BUF_MAPPED) {
                if (used & 4) {
 
        if (buf_priv->currently_mapped == I810_BUF_MAPPED) {
                if (used & 4) {
-                       *(u32 *) ((u32) buf_priv->virtual + used) = 0;
+                       *(u32 *) ((char *) buf_priv->virtual + used) = 0;
                        used += 4;
                }
 
                        used += 4;
                }
 
index 2cf3cc59ac64ede6928f8038e1bb80831b33a021..4f0e5746ab3382f30ff16e393aabca4f973e025d 100644 (file)
@@ -146,7 +146,7 @@ static int i830_map_buffer(drm_buf_t * buf, struct file *filp)
        if (IS_ERR((void *)virtual)) {  /* ugh */
                /* Real error */
                DRM_ERROR("mmap error\n");
        if (IS_ERR((void *)virtual)) {  /* ugh */
                /* Real error */
                DRM_ERROR("mmap error\n");
-               retcode = virtual;
+               retcode = PTR_ERR((void *)virtual);
                buf_priv->virtual = NULL;
        } else {
                buf_priv->virtual = (void __user *)virtual;
                buf_priv->virtual = NULL;
        } else {
                buf_priv->virtual = (void __user *)virtual;