mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: m.kozlowski@tuxland.pl
To: airlied@linux.ie, akpm@linux-foundation.org
Cc: dri-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH 04/23] drm_bufs.c: drm_alloc + memset to drm_alloc
Date: Mon, 27 Aug 2007 22:57:54 +0200	[thread overview]
Message-ID: <20070827211344.724173000@tuxland.pl> (raw)
In-Reply-To: <20070827205750.514001000@tuxland.pl>

[-- Attachment #1: drm_bufs.diff --]
[-- Type: text/plain, Size: 5704 bytes --]

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

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>

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

--

  parent reply	other threads:[~2007-08-27 21:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-27 20:57 [PATCH 00/23] drm: introduce drm_zalloc m.kozlowski
2007-08-27 20:57 ` [PATCH 01/23] introduce drm_zalloc as a drm_alloc + memset replacement m.kozlowski
2007-08-27 21:36   ` Mariusz Kozlowski
2007-08-28 19:58   ` Ian Romanick
2007-08-27 20:57 ` [PATCH 02/23] drm_agpsupport.c: drm_alloc + memset to drm_zalloc m.kozlowski
2007-08-27 20:57 ` [PATCH 03/23] drm_auth.c: " m.kozlowski
2007-08-27 20:57 ` m.kozlowski [this message]
2007-08-27 20:57 ` [PATCH 05/23] drm_dma.c: " m.kozlowski
2007-08-27 20:57 ` [PATCH 06/23] drm_drawable.c: drm_calloc " m.kozlowski
2007-08-27 20:57 ` [PATCH 07/23] drm_fops.c: drm_alloc + memset " m.kozlowski
2007-08-27 20:57 ` [PATCH 08/23] drm_irq.c: " m.kozlowski
2007-08-27 20:57 ` [PATCH 09/23] drm_scatter.c: drm_alloc + memset to drm_alloc m.kozlowski
2007-08-27 20:58 ` [PATCH 10/23] drm_sman.c: drm_calloc to drm_zalloc m.kozlowski
2007-08-27 20:58 ` [PATCH 11/23] drm_stub.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 12/23] i810_dma.c: drm_alloc + memset " m.kozlowski
2007-08-27 20:58 ` [PATCH 13/23] i830_dma.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 14/23] i915_dma.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 15/23] i915_irq.c: drm_calloc to drm_zalloc and bugfix m.kozlowski
2007-08-27 20:58 ` [PATCH 16/23] i915_mem.c: drm_alloc + memset to drm_zalloc m.kozlowski
2007-08-27 20:58 ` [PATCH 17/23] mga_dma.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 18/23] r128_cce.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 19/23] radeon_cp.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 20/23] radeon_mem.c: " m.kozlowski
2007-08-27 20:58 ` [PATCH 21/23] savage_bci.c: drm_alloc + memset to drm_zalloc and cleanup m.kozlowski
2007-08-27 20:58 ` [PATCH 22/23] sis_drv.c: drm_calloc to drm_zalloc m.kozlowski
2007-08-27 20:58 ` [PATCH 23/23] via_map.c: " m.kozlowski
2007-08-28 20:08 ` [PATCH 00/23] drm: introduce drm_zalloc Christoph Hellwig
2007-08-28 20:50   ` Dave Airlie
2007-08-30 16:20     ` Kristian Høgsberg
2007-08-30 16:24       ` Christoph Hellwig
2007-08-30 23:20         ` Dave Airlie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070827211344.724173000@tuxland.pl \
    --to=m.kozlowski@tuxland.pl \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®