[PATCH 04/23] drm_bufs.c: drm_alloc + memset to drm_alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch does dma_alloc and memset conversion to drm_zalloc or drm_calloc.

Signed-off-by: Mariusz Kozlowski <[email protected]>

 drivers/char/drm/drm_bufs.c | 44959 -> 44420 (-539 bytes)
 drivers/char/drm/drm_bufs.o | 149686 -> 146822 (-2864 bytes)

 drivers/char/drm/drm_bufs.c |   31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

--- linux-2.6.23-rc3-mm1.orig/drivers/char/drm/drm_bufs.c
+++ linux-2.6.23-rc3-mm1/drivers/char/drm/drm_bufs.c
@@ -277,14 +277,13 @@ static int drm_addmap_core(struct drm_de
 		return -EINVAL;
 	}

-	list = drm_alloc(sizeof(*list), DRM_MEM_MAPS);
+	list = drm_zalloc(sizeof(*list), DRM_MEM_MAPS);
 	if (!list) {
 		if (map->type == _DRM_REGISTERS)
 			iounmap(map->handle);
 		drm_free(map, sizeof(*map), DRM_MEM_MAPS);
 		return -EINVAL;
 	}
-	memset(list, 0, sizeof(*list));
 	list->map = map;

 	mutex_lock(&dev->struct_mutex);
@@ -627,14 +626,13 @@ int drm_addbufs_agp(struct drm_device *
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

 	entry->buf_size = size;
 	entry->page_order = page_order;
@@ -658,7 +656,7 @@ int drm_addbufs_agp(struct drm_device *
 		buf->filp = NULL;

 		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
+		buf->dev_private = drm_zalloc(buf->dev_priv_size, DRM_MEM_BUFS);
 		if (!buf->dev_private) {
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
@@ -667,7 +665,6 @@ int drm_addbufs_agp(struct drm_device *
 			atomic_dec(&dev->buf_alloc);
 			return -ENOMEM;
 		}
-		memset(buf->dev_private, 0, buf->dev_priv_size);

 		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);

@@ -783,16 +780,15 @@ int drm_addbufs_pci(struct drm_device *
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

-	entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
+	entry->seglist = drm_calloc(count, sizeof(*entry->seglist),
 				   DRM_MEM_SEGS);
 	if (!entry->seglist) {
 		drm_free(entry->buflist,
@@ -801,7 +797,6 @@ int drm_addbufs_pci(struct drm_device *
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->seglist, 0, count * sizeof(*entry->seglist));

 	/* Keep the original pagelist until we know all the allocations
 	 * have succeeded
@@ -869,7 +864,7 @@ int drm_addbufs_pci(struct drm_device *
 			buf->filp = NULL;

 			buf->dev_priv_size = dev->driver->dev_priv_size;
-			buf->dev_private = drm_alloc(buf->dev_priv_size,
+			buf->dev_private = drm_zalloc(buf->dev_priv_size,
 						     DRM_MEM_BUFS);
 			if (!buf->dev_private) {
 				/* Set count correctly so we free the proper amount. */
@@ -885,7 +880,6 @@ int drm_addbufs_pci(struct drm_device *
 				atomic_dec(&dev->buf_alloc);
 				return -ENOMEM;
 			}
-			memset(buf->dev_private, 0, buf->dev_priv_size);

 			DRM_DEBUG("buffer %d @ %p\n",
 				  entry->buf_count, buf->address);
@@ -1015,14 +1009,13 @@ static int drm_addbufs_sg(struct drm_dev
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

 	entry->buf_size = size;
 	entry->page_order = page_order;
@@ -1047,7 +1040,7 @@ static int drm_addbufs_sg(struct drm_dev
 		buf->filp = NULL;

 		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
+		buf->dev_private = drm_zalloc(buf->dev_priv_size, DRM_MEM_BUFS);
 		if (!buf->dev_private) {
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
@@ -1057,8 +1050,6 @@ static int drm_addbufs_sg(struct drm_dev
 			return -ENOMEM;
 		}

-		memset(buf->dev_private, 0, buf->dev_priv_size);
-
 		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);

 		offset += alignment;
@@ -1177,14 +1168,13 @@ static int drm_addbufs_fb(struct drm_dev
 		return -EINVAL;
 	}

-	entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+	entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
 				   DRM_MEM_BUFS);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
-	memset(entry->buflist, 0, count * sizeof(*entry->buflist));

 	entry->buf_size = size;
 	entry->page_order = page_order;
@@ -1208,7 +1198,7 @@ static int drm_addbufs_fb(struct drm_dev
 		buf->filp = NULL;

 		buf->dev_priv_size = dev->driver->dev_priv_size;
-		buf->dev_private = drm_alloc(buf->dev_priv_size, DRM_MEM_BUFS);
+		buf->dev_private = drm_zalloc(buf->dev_priv_size, DRM_MEM_BUFS);
 		if (!buf->dev_private) {
 			/* Set count correctly so we free the proper amount. */
 			entry->buf_count = count;
@@ -1217,7 +1207,6 @@ static int drm_addbufs_fb(struct drm_dev
 			atomic_dec(&dev->buf_alloc);
 			return -ENOMEM;
 		}
-		memset(buf->dev_private, 0, buf->dev_priv_size);

 		DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux