summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2009-03-26 07:25:07 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2009-03-26 07:25:07 +0000
commit12513825f03c1f486b0442b73d892b38fe1cd2a4 (patch)
tree05941471ca03e5ce33a0cbbafe0e05bb77e35739
parenta09a0a7005c9f8faae78ae1dc0b83c57bec59387 (diff)
The drm_* allocation functions have been #defined to not use most of
their arguments for a while. Actually go through the code and remove the extraneous arguments. Makes things easier to read.
-rw-r--r--sys/dev/pci/drm/drmP.h37
-rw-r--r--sys/dev/pci/drm/drm_agpsupport.c8
-rw-r--r--sys/dev/pci/drm/drm_auth.c4
-rw-r--r--sys/dev/pci/drm/drm_bufs.c69
-rw-r--r--sys/dev/pci/drm/drm_context.c4
-rw-r--r--sys/dev/pci/drm/drm_dma.c19
-rw-r--r--sys/dev/pci/drm/drm_drv.c12
-rw-r--r--sys/dev/pci/drm/drm_heap.c12
-rw-r--r--sys/dev/pci/drm/drm_irq.c5
-rw-r--r--sys/dev/pci/drm/drm_memory.c10
-rw-r--r--sys/dev/pci/drm/drm_scatter.c4
-rw-r--r--sys/dev/pci/drm/i915_mem.c4
-rw-r--r--sys/dev/pci/drm/mach64_dma.c11
-rw-r--r--sys/dev/pci/drm/mach64_state.c10
-rw-r--r--sys/dev/pci/drm/mga_dma.c7
-rw-r--r--sys/dev/pci/drm/r128_cce.c5
-rw-r--r--sys/dev/pci/drm/r128_state.c84
-rw-r--r--sys/dev/pci/drm/radeon_mem.c4
-rw-r--r--sys/dev/pci/drm/radeon_state.c10
-rw-r--r--sys/dev/pci/drm/savage_bci.c13
-rw-r--r--sys/dev/pci/drm/savage_state.c16
-rw-r--r--sys/dev/pci/drm/sis_ds.c14
22 files changed, 146 insertions, 216 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 8c1af418073..7ad25792d2d 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -75,30 +75,6 @@
#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
-#define DRM_MEM_DMA 0
-#define DRM_MEM_SAREA 1
-#define DRM_MEM_DRIVER 2
-#define DRM_MEM_MAGIC 3
-#define DRM_MEM_IOCTLS 4
-#define DRM_MEM_MAPS 5
-#define DRM_MEM_BUFS 6
-#define DRM_MEM_SEGS 7
-#define DRM_MEM_PAGES 8
-#define DRM_MEM_FILES 9
-#define DRM_MEM_QUEUES 10
-#define DRM_MEM_CMDS 11
-#define DRM_MEM_MAPPINGS 12
-#define DRM_MEM_BUFLISTS 13
-#define DRM_MEM_AGPLISTS 14
-#define DRM_MEM_TOTALAGP 15
-#define DRM_MEM_BOUNDAGP 16
-#define DRM_MEM_CTXBITMAP 17
-#define DRM_MEM_CTXLIST 18
-#define DRM_MEM_STUB 19
-#define DRM_MEM_SGLISTS 20
-#define DRM_MEM_DRAWABLE 21
-#define DRM_MEM_MM 22
-
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
/* Internal types and structures */
@@ -557,15 +533,10 @@ drm_pci_id_list_t *drm_find_description(int , int , drm_pci_id_list_t *);
struct drm_file *drm_find_file_by_minor(struct drm_device *, int);
/* Memory management support (drm_memory.c) */
-void *_drm_alloc(size_t);
-#define drm_alloc(size, area) _drm_alloc(size)
-void *_drm_calloc(size_t, size_t);
-#define drm_calloc(nmemb, size, area) _drm_calloc(nmemb, size)
-void *_drm_realloc(void *, size_t, size_t);
-#define drm_realloc(old, oldsz, size, area) _drm_realloc(old, oldsz, size)
-void _drm_free(void *);
-#define drm_free(ptr, size, area) do { _drm_free(ptr); (void)(size); \
-} while( /*CONSTCOND*/ 0)
+void *drm_alloc(size_t);
+void *drm_calloc(size_t, size_t);
+void *drm_realloc(void *, size_t, size_t);
+void drm_free(void *);
void *drm_ioremap(struct drm_device *, drm_local_map_t *);
void drm_ioremapfree(drm_local_map_t *);
int drm_mtrr_add(unsigned long, size_t, int);
diff --git a/sys/dev/pci/drm/drm_agpsupport.c b/sys/dev/pci/drm/drm_agpsupport.c
index 9125cde4a7a..1a2c89e01cb 100644
--- a/sys/dev/pci/drm/drm_agpsupport.c
+++ b/sys/dev/pci/drm/drm_agpsupport.c
@@ -154,7 +154,7 @@ drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
if (dev->agp == NULL || !dev->agp->acquired)
return (EINVAL);
- entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS);
+ entry = drm_alloc(sizeof(*entry));
if (entry == NULL)
return (ENOMEM);
@@ -164,7 +164,7 @@ drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request)
handle = agp_alloc_memory(dev->agp->agpdev, type,
pages << AGP_PAGE_SHIFT);
if (handle == NULL) {
- drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ drm_free(entry);
return (ENOMEM);
}
@@ -291,7 +291,7 @@ drm_agp_remove_entry(struct drm_device *dev, struct drm_agp_mem *entry)
if (entry->bound)
agp_unbind_memory(dev->agp->agpdev, entry->handle);
agp_free_memory(dev->agp->agpdev, entry->handle);
- drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ drm_free(entry);
}
void
@@ -360,7 +360,7 @@ drm_agp_init(void)
DRM_DEBUG("agp_available = %d\n", agp_available);
if (agp_available) {
- head = drm_calloc(1, sizeof(*head), DRM_MEM_AGPLISTS);
+ head = drm_calloc(1, sizeof(*head));
if (head == NULL)
return (NULL);
head->agpdev = agpdev;
diff --git a/sys/dev/pci/drm/drm_auth.c b/sys/dev/pci/drm/drm_auth.c
index 3a7e4af340e..c2fd04709a8 100644
--- a/sys/dev/pci/drm/drm_auth.c
+++ b/sys/dev/pci/drm/drm_auth.c
@@ -53,7 +53,7 @@ drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
if (file_priv->magic) {
auth->magic = file_priv->magic;
} else {
- entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
+ entry = drm_alloc(sizeof(*entry));
if (entry == NULL)
return (ENOMEM);
DRM_LOCK();
@@ -93,7 +93,7 @@ drm_authmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
SPLAY_REMOVE(drm_magic_tree, &dev->magiclist, pt);
DRM_UNLOCK();
- drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ drm_free(pt);
return (0);
}
diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c
index 3c95734e9e7..a77336a3c89 100644
--- a/sys/dev/pci/drm/drm_bufs.c
+++ b/sys/dev/pci/drm/drm_bufs.c
@@ -113,7 +113,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
/* Allocate a new map structure, fill it in, and do any type-specific
* initialization necessary.
*/
- map = drm_calloc(1, sizeof(*map), DRM_MEM_MAPS);
+ map = drm_calloc(1, sizeof(*map));
if (map == NULL) {
DRM_LOCK();
return ENOMEM;
@@ -131,7 +131,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
if (ret) {
DRM_ERROR("can't find free offset\n");
DRM_UNLOCK();
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
return (ret);
}
DRM_UNLOCK();
@@ -178,7 +178,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
}
if (!TAILQ_EMPTY(&dev->agp->memory) && !valid) {
DRM_UNLOCK();
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
DRM_ERROR("invalid agp map requested\n");
return (EACCES);
}
@@ -187,7 +187,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
break;
case _DRM_SCATTER_GATHER:
if (dev->sg == NULL) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
return (EINVAL);
}
map->offset += dev->sg->handle;
@@ -206,7 +206,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
map->dmamem = drm_dmamem_alloc(dev->dmat, map->size, align,
1, map->size, 0, 0);
if (map->dmamem == NULL) {
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
return (ENOMEM);
}
map->handle = map->dmamem->kva;
@@ -217,7 +217,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
if (dev->lock.hw_lock != NULL) {
DRM_UNLOCK();
drm_dmamem_free(dev->dmat, map->dmamem);
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
return (EBUSY);
}
dev->lock.hw_lock = map->handle;
@@ -226,7 +226,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
break;
default:
DRM_ERROR("Bad map type %d\n", map->type);
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
return EINVAL;
}
@@ -313,7 +313,7 @@ drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map)
/* NOCOALESCE set, can't fail */
extent_free(dev->handle_ext, map->ext, map->size, EX_NOWAIT);
- drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map);
}
/* Remove a map private from list and deallocate resources if the mapping
@@ -417,8 +417,7 @@ drm_do_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request)
entry = &dma->bufs[order];
- entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
- DRM_MEM_BUFS);
+ entry->buflist = drm_calloc(count, sizeof(*entry->buflist));
if (entry->buflist == NULL)
return ENOMEM;
@@ -438,8 +437,7 @@ drm_do_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request)
buf->pending = 0;
buf->file_priv = NULL;
- buf->dev_private = drm_calloc(1, dev->driver->buf_priv_size,
- DRM_MEM_BUFS);
+ buf->dev_private = drm_calloc(1, dev->driver->buf_priv_size);
if (buf->dev_private == NULL) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
@@ -457,7 +455,7 @@ drm_do_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request)
/* OpenBSD lacks realloc in kernel */
temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
+ (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist));
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf(dev, entry);
@@ -515,25 +513,20 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request)
entry = &dma->bufs[order];
- entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- entry->seglist = drm_calloc(count, sizeof(*entry->seglist),
- DRM_MEM_BUFS);
+ entry->buflist = drm_calloc(count, sizeof(*entry->buflist));
+ entry->seglist = drm_calloc(count, sizeof(*entry->seglist));
/* Keep the original pagelist until we know all the allocations
* have succeeded
*/
temp_pagelist = drm_calloc((dma->page_count + (count << page_order)),
- sizeof(*dma->pagelist), DRM_MEM_BUFS);
+ sizeof(*dma->pagelist));
if (entry->buflist == NULL || entry->seglist == NULL ||
temp_pagelist == NULL) {
- drm_free(temp_pagelist, (dma->page_count + (count <<
- page_order)) * sizeof(*dma->pagelist), DRM_MEM_BUFS);
- drm_free(entry->seglist, count * sizeof(*entry->seglist),
- DRM_MEM_BUFS);
- drm_free(entry->buflist, count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
+ drm_free(temp_pagelist);
+ drm_free(entry->seglist);
+ drm_free(entry->buflist);
return ENOMEM;
}
@@ -556,9 +549,7 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request)
entry->buf_count = count;
entry->seg_count = count;
drm_cleanup_buf(dev, entry);
- drm_free(temp_pagelist, (dma->page_count +
- (count << page_order)) * sizeof(*dma->pagelist),
- DRM_MEM_BUFS);
+ drm_free(temp_pagelist);
return ENOMEM;
}
@@ -584,16 +575,13 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request)
buf->file_priv = NULL;
buf->dev_private = drm_calloc(1,
- dev->driver->buf_priv_size, DRM_MEM_BUFS);
+ dev->driver->buf_priv_size);
if (buf->dev_private == NULL) {
/* Set count so we free the proper amount. */
entry->buf_count = count;
entry->seg_count = count;
drm_cleanup_buf(dev, entry);
- drm_free(temp_pagelist, (dma->page_count +
- (count << page_order)) *
- sizeof(*dma->pagelist),
- DRM_MEM_BUFS);
+ drm_free(temp_pagelist);
return ENOMEM;
}
@@ -605,13 +593,11 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request)
temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
+ (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist));
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf(dev, entry);
- drm_free(temp_pagelist, (dma->page_count +
- (count << page_order)) * sizeof(*dma->pagelist),
- DRM_MEM_BUFS);
+ drm_free(temp_pagelist);
return ENOMEM;
}
dma->buflist = temp_buflist;
@@ -622,8 +608,7 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request)
/* No allocations failed, so now we can replace the orginal pagelist
* with the new one.
*/
- drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_BUFS);
+ drm_free(dma->pagelist);
dma->pagelist = temp_pagelist;
dma->buf_count += entry->buf_count;
@@ -678,8 +663,7 @@ drm_do_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request)
entry = &dma->bufs[order];
- entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
- DRM_MEM_BUFS);
+ entry->buflist = drm_calloc(count, sizeof(*entry->buflist));
if (entry->buflist == NULL)
return ENOMEM;
@@ -699,8 +683,7 @@ drm_do_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request)
buf->pending = 0;
buf->file_priv = NULL;
- buf->dev_private = drm_calloc(1, dev->driver->buf_priv_size,
- DRM_MEM_BUFS);
+ buf->dev_private = drm_calloc(1, dev->driver->buf_priv_size);
if (buf->dev_private == NULL) {
/* Set count correctly so we free the proper amount. */
entry->buf_count = count;
@@ -719,7 +702,7 @@ drm_do_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request)
temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
+ (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist));
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf(dev, entry);
diff --git a/sys/dev/pci/drm/drm_context.c b/sys/dev/pci/drm/drm_context.c
index 67538152db4..7c3135bb422 100644
--- a/sys/dev/pci/drm/drm_context.c
+++ b/sys/dev/pci/drm/drm_context.c
@@ -82,7 +82,7 @@ drm_ctxbitmap_init(struct drm_device *dev)
int i, temp;
- bitmap = drm_calloc(1, PAGE_SIZE, DRM_MEM_CTXBITMAP);
+ bitmap = drm_calloc(1, PAGE_SIZE);
if (bitmap == NULL)
return (ENOMEM);
DRM_LOCK();
@@ -106,7 +106,7 @@ drm_ctxbitmap_cleanup(struct drm_device *dev)
bitmap = dev->ctx_bitmap;
dev->ctx_bitmap = NULL;
DRM_UNLOCK();
- drm_free(bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
+ drm_free(bitmap);
}
int
diff --git a/sys/dev/pci/drm/drm_dma.c b/sys/dev/pci/drm/drm_dma.c
index e0385def268..2f527efcb5c 100644
--- a/sys/dev/pci/drm/drm_dma.c
+++ b/sys/dev/pci/drm/drm_dma.c
@@ -42,7 +42,7 @@ int
drm_dma_setup(struct drm_device *dev)
{
- dev->dma = drm_calloc(1, sizeof(*dev->dma), DRM_MEM_DRIVER);
+ dev->dma = drm_calloc(1, sizeof(*dev->dma));
if (dev->dma == NULL)
return ENOMEM;
@@ -61,19 +61,16 @@ drm_cleanup_buf(struct drm_device *dev, drm_buf_entry_t *entry)
if (entry->seg_count) {
for (i = 0; i < entry->seg_count; i++)
drm_dmamem_free(dev->dmat, entry->seglist[i]);
- drm_free(entry->seglist, entry->seg_count *
- sizeof(*entry->seglist), DRM_MEM_BUFS);
+ drm_free(entry->seglist);
entry->seg_count = 0;
}
if (entry->buf_count) {
for (i = 0; i < entry->buf_count; i++) {
- drm_free(entry->buflist[i].dev_private,
- dev->driver->buf_priv_size, DRM_MEM_BUFS);
+ drm_free(entry->buflist[i].dev_private);
}
- drm_free(entry->buflist, entry->buf_count *
- sizeof(*entry->buflist), DRM_MEM_BUFS);
+ drm_free(entry->buflist);
entry->buf_count = 0;
}
@@ -92,11 +89,9 @@ drm_dma_takedown(struct drm_device *dev)
for (i = 0; i <= DRM_MAX_ORDER; i++)
drm_cleanup_buf(dev, &dma->bufs[i]);
- drm_free(dma->buflist, dma->buf_count * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
- drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_BUFS);
- drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DMA);
+ drm_free(dma->buflist);
+ drm_free(dma->pagelist);
+ drm_free(dev->dma);
dev->dma = NULL;
DRM_SPINUNINIT(&dev->dma_lock);
}
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index a862478b9c3..04d7eb1ed90 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -205,7 +205,7 @@ drm_detach(struct device *self, int flags)
if (dev->agp != NULL) {
- drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ drm_free(dev->agp);
dev->agp = NULL;
}
@@ -317,7 +317,7 @@ drm_lastclose(struct drm_device *dev)
/* Clear pid list */
while ((pt = SPLAY_ROOT(&dev->magiclist)) != NULL) {
SPLAY_REMOVE(drm_magic_tree, &dev->magiclist, pt);
- drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ drm_free(pt);
}
if (dev->sg != NULL) {
@@ -399,7 +399,7 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
/* always allocate at least enough space for our data */
priv = drm_calloc(1, max(dev->driver->file_priv_size,
- sizeof(*priv)), DRM_MEM_FILES);
+ sizeof(*priv)));
if (priv == NULL) {
ret = ENOMEM;
goto err;
@@ -436,8 +436,7 @@ drmopen(dev_t kdev, int flags, int fmt, struct proc *p)
return (0);
free_priv:
- drm_free(priv, max(dev->driver->file_priv_size,
- sizeof(*priv)), DRM_MEM_FILES);
+ drm_free(priv);
err:
DRM_LOCK();
--dev->open_count;
@@ -518,8 +517,7 @@ drmclose(dev_t kdev, int flags, int fmt, struct proc *p)
DRM_LOCK();
TAILQ_REMOVE(&dev->files, file_priv, link);
- drm_free(file_priv, max(dev->driver->file_priv_size,
- sizeof(*file_priv)), DRM_MEM_FILES);
+ drm_free(file_priv);
done:
if (--dev->open_count == 0) {
diff --git a/sys/dev/pci/drm/drm_heap.c b/sys/dev/pci/drm/drm_heap.c
index ed55f2401be..0a62863b2c8 100644
--- a/sys/dev/pci/drm/drm_heap.c
+++ b/sys/dev/pci/drm/drm_heap.c
@@ -44,8 +44,7 @@ drm_split_block(struct drm_heap *heap, struct drm_mem *p, int start,
{
/* Maybe cut off the start of an existing block */
if (start > p->start) {
- struct drm_mem *newblock =
- drm_alloc(sizeof(*newblock), DRM_MEM_BUFS);
+ struct drm_mem *newblock = drm_alloc(sizeof(*newblock));
if (newblock == NULL)
goto out;
newblock->start = start;
@@ -58,8 +57,7 @@ drm_split_block(struct drm_heap *heap, struct drm_mem *p, int start,
/* Maybe cut off the end of an existing block */
if (size < p->size) {
- struct drm_mem *newblock =
- drm_alloc(sizeof(*newblock), DRM_MEM_BUFS);
+ struct drm_mem *newblock = drm_alloc(sizeof(*newblock));
if (newblock == NULL)
goto out;
newblock->start = start + size;
@@ -115,14 +113,14 @@ drm_free_block(struct drm_heap *heap, struct drm_mem *p)
q->file_priv == NULL) {
p->size += q->size;
TAILQ_REMOVE(heap, q, link);
- drm_free(q, sizeof(*q), DRM_MEM_BUFS);
+ drm_free(q);
}
if ((q = TAILQ_PREV(p, drm_heap, link)) != TAILQ_END(heap) &&
q->file_priv == NULL) {
q->size += p->size;
TAILQ_REMOVE(heap, p, link);
- drm_free(p, sizeof(*p), DRM_MEM_BUFS);
+ drm_free(p);
}
}
@@ -136,7 +134,7 @@ drm_init_heap(struct drm_heap *heap, int start, int size)
if (!TAILQ_EMPTY(heap))
return (EBUSY);
- if ((blocks = drm_alloc(sizeof(*blocks), DRM_MEM_BUFS)) == NULL)
+ if ((blocks = drm_alloc(sizeof(*blocks))) == NULL)
return (ENOMEM);
blocks->start = start;
diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c
index 7e38de2a1de..12a99740caa 100644
--- a/sys/dev/pci/drm/drm_irq.c
+++ b/sys/dev/pci/drm/drm_irq.c
@@ -178,8 +178,7 @@ drm_vblank_cleanup(struct drm_device *dev)
vblank_disable(dev);
- drm_free(dev->vblank, sizeof(*dev->vblank) *
- dev->num_crtcs, M_DRM);
+ drm_free(dev->vblank);
dev->vblank = NULL;
dev->num_crtcs = 0;
@@ -193,7 +192,7 @@ drm_vblank_init(struct drm_device *dev, int num_crtcs)
mtx_init(&dev->vbl_lock, IPL_BIO);
dev->num_crtcs = num_crtcs;
- dev->vblank = drm_calloc(num_crtcs, sizeof(*dev->vblank), M_DRM);
+ dev->vblank = drm_calloc(num_crtcs, sizeof(*dev->vblank));
if (dev->vblank == NULL)
goto err;
diff --git a/sys/dev/pci/drm/drm_memory.c b/sys/dev/pci/drm/drm_memory.c
index fd53412b0dc..031d23cda98 100644
--- a/sys/dev/pci/drm/drm_memory.c
+++ b/sys/dev/pci/drm/drm_memory.c
@@ -39,13 +39,13 @@
#include "drmP.h"
void*
-_drm_alloc(size_t size)
+drm_alloc(size_t size)
{
- return malloc(size, M_DRM, M_NOWAIT);
+ return (malloc(size, M_DRM, M_NOWAIT));
}
void *
-_drm_calloc(size_t nmemb, size_t size)
+drm_calloc(size_t nmemb, size_t size)
{
if (nmemb == 0 || SIZE_MAX / nmemb < size)
return (NULL);
@@ -54,7 +54,7 @@ _drm_calloc(size_t nmemb, size_t size)
}
void *
-_drm_realloc(void *oldpt, size_t oldsize, size_t size)
+drm_realloc(void *oldpt, size_t oldsize, size_t size)
{
void *pt;
@@ -69,7 +69,7 @@ _drm_realloc(void *oldpt, size_t oldsize, size_t size)
}
void
-_drm_free(void *pt)
+drm_free(void *pt)
{
if (pt != NULL)
free(pt, M_DRM);
diff --git a/sys/dev/pci/drm/drm_scatter.c b/sys/dev/pci/drm/drm_scatter.c
index 14e9ba2ac9d..592ca8b1f00 100644
--- a/sys/dev/pci/drm/drm_scatter.c
+++ b/sys/dev/pci/drm/drm_scatter.c
@@ -42,7 +42,7 @@ drm_sg_cleanup(struct drm_device *dev, struct drm_sg_mem *entry)
return;
drm_dmamem_free(dev->dmat, entry->mem);
- drm_free(entry, sizeof(entry), DRM_MEM_SGLISTS);
+ drm_free(entry);
}
int
@@ -55,7 +55,7 @@ drm_sg_alloc(struct drm_device * dev, struct drm_scatter_gather *request)
if (dev->sg != NULL)
return (EINVAL);
- entry = drm_calloc(1, sizeof(*entry), DRM_MEM_SGLISTS);
+ entry = drm_calloc(1, sizeof(*entry));
if (entry == NULL)
return (ENOMEM);
diff --git a/sys/dev/pci/drm/i915_mem.c b/sys/dev/pci/drm/i915_mem.c
index c2559eee733..429b36da7ec 100644
--- a/sys/dev/pci/drm/i915_mem.c
+++ b/sys/dev/pci/drm/i915_mem.c
@@ -110,7 +110,7 @@ i915_mem_release(struct drm_device * dev, struct drm_file *file_priv,
q->file_priv == NULL) {
p->size += q->size;
TAILQ_REMOVE(heap, q, link);
- drm_free(q, sizeof(*q), DRM_MEM_DRIVER);
+ drm_free(q);
}
q = TAILQ_NEXT(p, link);
}
@@ -128,7 +128,7 @@ i915_mem_takedown(struct drm_heap *heap)
while ((p = TAILQ_FIRST(heap)) != NULL) {
TAILQ_REMOVE(heap, p, link);
- drm_free(p, sizeof(*p), DRM_MEM_BUFLISTS);
+ drm_free(p);
}
}
diff --git a/sys/dev/pci/drm/mach64_dma.c b/sys/dev/pci/drm/mach64_dma.c
index 8ea1fcba8db..73f84d1d4a9 100644
--- a/sys/dev/pci/drm/mach64_dma.c
+++ b/sys/dev/pci/drm/mach64_dma.c
@@ -1439,10 +1439,7 @@ int mach64_init_freelist(struct drm_device * dev)
DRM_DEBUG("adding %d buffers to freelist\n", dma->buf_count);
for (i = 0; i < dma->buf_count; i++) {
- if ((entry =
- (drm_mach64_freelist_t *)
- drm_calloc(1, sizeof(drm_mach64_freelist_t),
- DRM_MEM_BUFLISTS)) == NULL)
+ if ((entry = drm_calloc(1, sizeof(*entry))) == NULL)
return ENOMEM;
entry->buf = dma->buflist[i];
ptr = &entry->list;
@@ -1464,18 +1461,18 @@ void mach64_destroy_freelist(struct drm_device * dev)
list_for_each_safe(ptr, tmp, &dev_priv->pending) {
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry);
}
list_for_each_safe(ptr, tmp, &dev_priv->placeholders) {
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry);
}
list_for_each_safe(ptr, tmp, &dev_priv->free_list) {
list_del(ptr);
entry = list_entry(ptr, drm_mach64_freelist_t, list);
- drm_free(entry, sizeof(*entry), DRM_MEM_BUFLISTS);
+ drm_free(entry);
}
}
diff --git a/sys/dev/pci/drm/mach64_state.c b/sys/dev/pci/drm/mach64_state.c
index 97d0e6508e1..7f597f50204 100644
--- a/sys/dev/pci/drm/mach64_state.c
+++ b/sys/dev/pci/drm/mach64_state.c
@@ -471,12 +471,12 @@ static __inline__ int copy_from_user_vertex(u32 *to,
unsigned long n = bytes; /* dwords remaining in buffer */
u32 *from, *orig_from;
- from = drm_alloc(bytes, DRM_MEM_DRIVER);
+ from = drm_alloc(bytes);
if (from == NULL)
return ENOMEM;
if (DRM_COPY_FROM_USER(from, ufrom, bytes)) {
- drm_free(from, bytes, DRM_MEM_DRIVER);
+ drm_free(from);
return EFAULT;
}
orig_from = from; /* we'll be modifying the "from" ptr, so save it */
@@ -507,19 +507,19 @@ static __inline__ int copy_from_user_vertex(u32 *to,
to += count;
} else {
DRM_ERROR("Got bad command: 0x%04x\n", reg);
- drm_free(orig_from, bytes, DRM_MEM_DRIVER);
+ drm_free(orig_from);
return EACCES;
}
} else {
DRM_ERROR
("Got bad command count(=%u) dwords remaining=%lu\n",
count, n);
- drm_free(orig_from, bytes, DRM_MEM_DRIVER);
+ drm_free(orig_from);
return EINVAL;
}
}
- drm_free(orig_from, bytes, DRM_MEM_DRIVER);
+ drm_free(orig_from);
if (n == 0)
return 0;
else {
diff --git a/sys/dev/pci/drm/mga_dma.c b/sys/dev/pci/drm/mga_dma.c
index 88a7c5b772e..295a39b4911 100644
--- a/sys/dev/pci/drm/mga_dma.c
+++ b/sys/dev/pci/drm/mga_dma.c
@@ -253,7 +253,7 @@ static int mga_freelist_init(struct drm_device * dev, drm_mga_private_t * dev_pr
int i;
DRM_DEBUG("count=%d\n", dma->buf_count);
- dev_priv->head = drm_calloc(1, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+ dev_priv->head = drm_calloc(1, sizeof(*(dev_priv->head)));
if (dev_priv->head == NULL)
return ENOMEM;
@@ -263,8 +263,7 @@ static int mga_freelist_init(struct drm_device * dev, drm_mga_private_t * dev_pr
buf = dma->buflist[i];
buf_priv = (drm_mga_buf_priv_t *)buf;
- entry = drm_calloc(1, sizeof(drm_mga_freelist_t),
- DRM_MEM_DRIVER);
+ entry = drm_calloc(1, sizeof(*entry));
if (entry == NULL)
return ENOMEM;
@@ -297,7 +296,7 @@ static void mga_freelist_cleanup(struct drm_device * dev)
entry = dev_priv->head;
while (entry) {
next = entry->next;
- drm_free(entry, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+ drm_free(entry);
entry = next;
}
diff --git a/sys/dev/pci/drm/r128_cce.c b/sys/dev/pci/drm/r128_cce.c
index 272a9fe6713..aae7092cc79 100644
--- a/sys/dev/pci/drm/r128_cce.c
+++ b/sys/dev/pci/drm/r128_cce.c
@@ -728,8 +728,7 @@ static int r128_freelist_init(struct drm_device * dev)
drm_r128_freelist_t *entry;
int i;
- dev_priv->head = drm_calloc(1, sizeof(drm_r128_freelist_t),
- DRM_MEM_DRIVER);
+ dev_priv->head = drm_calloc(1, sizeof(*dev_priv->head));
if (dev_priv->head == NULL)
return ENOMEM;
@@ -739,7 +738,7 @@ static int r128_freelist_init(struct drm_device * dev)
buf = dma->buflist[i];
buf_priv = buf->dev_private;
- entry = drm_alloc(sizeof(drm_r128_freelist_t), DRM_MEM_DRIVER);
+ entry = drm_alloc(sizeof(*entry));
if (!entry)
return ENOMEM;
diff --git a/sys/dev/pci/drm/r128_state.c b/sys/dev/pci/drm/r128_state.c
index e7c8c58254b..a9fff384d5f 100644
--- a/sys/dev/pci/drm/r128_state.c
+++ b/sys/dev/pci/drm/r128_state.c
@@ -838,24 +838,24 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
}
buffer_size = depth->n * sizeof(u32);
- buffer = drm_alloc(buffer_size, DRM_MEM_BUFS);
+ buffer = drm_alloc(buffer_size);
if (buffer == NULL)
return ENOMEM;
if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free(buffer);
return EFAULT;
}
mask_size = depth->n * sizeof(u8);
if (depth->mask) {
- mask = drm_alloc(mask_size, DRM_MEM_BUFS);
+ mask = drm_alloc(mask_size);
if (mask == NULL) {
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free(buffer);
return ENOMEM;
}
if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
- drm_free(mask, mask_size, DRM_MEM_BUFS);
+ drm_free(buffer);
+ drm_free(mask);
return EFAULT;
}
@@ -882,7 +882,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
}
}
- drm_free(mask, mask_size, DRM_MEM_BUFS);
+ drm_free(mask);
} else {
for (i = 0; i < count; i++, x++) {
BEGIN_RING(6);
@@ -906,7 +906,7 @@ static int r128_cce_dispatch_write_span(struct drm_device * dev,
}
}
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free(buffer);
return 0;
}
@@ -928,54 +928,54 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = drm_alloc(xbuf_size, DRM_MEM_BUFS);
+ x = drm_alloc(xbuf_size);
if (x == NULL) {
return ENOMEM;
}
- y = drm_alloc(ybuf_size, DRM_MEM_BUFS);
+ y = drm_alloc(ybuf_size);
if (y == NULL) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
+ drm_free(x);
return ENOMEM;
}
if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
return EFAULT;
}
if (DRM_COPY_FROM_USER(y, depth->y, xbuf_size)) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
return EFAULT;
}
buffer_size = depth->n * sizeof(u32);
- buffer = drm_alloc(buffer_size, DRM_MEM_BUFS);
+ buffer = drm_alloc(buffer_size);
if (buffer == NULL) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
return ENOMEM;
}
if (DRM_COPY_FROM_USER(buffer, depth->buffer, buffer_size)) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
+ drm_free(buffer);
return EFAULT;
}
if (depth->mask) {
mask_size = depth->n * sizeof(u8);
- mask = drm_alloc(mask_size, DRM_MEM_BUFS);
+ mask = drm_alloc(mask_size);
if (mask == NULL) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
+ drm_free(buffer);
return ENOMEM;
}
if (DRM_COPY_FROM_USER(mask, depth->mask, mask_size)) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
- drm_free(mask, mask_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
+ drm_free(buffer);
+ drm_free(mask);
return EFAULT;
}
@@ -1002,7 +1002,7 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
}
}
- drm_free(mask, mask_size, DRM_MEM_BUFS);
+ drm_free(mask);
} else {
for (i = 0; i < count; i++) {
BEGIN_RING(6);
@@ -1026,9 +1026,9 @@ static int r128_cce_dispatch_write_pixels(struct drm_device * dev,
}
}
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
- drm_free(buffer, buffer_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
+ drm_free(buffer);
return 0;
}
@@ -1095,23 +1095,23 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
xbuf_size = count * sizeof(*x);
ybuf_size = count * sizeof(*y);
- x = drm_alloc(xbuf_size, DRM_MEM_BUFS);
+ x = drm_alloc(xbuf_size);
if (x == NULL) {
return ENOMEM;
}
- y = drm_alloc(ybuf_size, DRM_MEM_BUFS);
+ y = drm_alloc(ybuf_size);
if (y == NULL) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
+ drm_free(x);
return ENOMEM;
}
if (DRM_COPY_FROM_USER(x, depth->x, xbuf_size)) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
return EFAULT;
}
if (DRM_COPY_FROM_USER(y, depth->y, ybuf_size)) {
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
return EFAULT;
}
@@ -1138,8 +1138,8 @@ static int r128_cce_dispatch_read_pixels(struct drm_device * dev,
ADVANCE_RING();
}
- drm_free(x, xbuf_size, DRM_MEM_BUFS);
- drm_free(y, ybuf_size, DRM_MEM_BUFS);
+ drm_free(x);
+ drm_free(y);
return 0;
}
diff --git a/sys/dev/pci/drm/radeon_mem.c b/sys/dev/pci/drm/radeon_mem.c
index f753edc80b5..d095959bde7 100644
--- a/sys/dev/pci/drm/radeon_mem.c
+++ b/sys/dev/pci/drm/radeon_mem.c
@@ -57,7 +57,7 @@ radeon_mem_release(struct drm_file *file_priv, struct drm_heap *heap)
q->file_priv == NULL) {
p->size += q->size;
TAILQ_REMOVE(heap, q, link);
- drm_free(q, sizeof(*q), DRM_MEM_DRIVER);
+ drm_free(q);
}
q = TAILQ_NEXT(p, link);
}
@@ -75,7 +75,7 @@ radeon_mem_takedown(struct drm_heap *heap)
while ((p = TAILQ_FIRST(heap)) != NULL) {
TAILQ_REMOVE(heap, p, link);
- drm_free(p, sizeof(*p), DRM_MEM_DRIVER);
+ drm_free(p);
}
}
diff --git a/sys/dev/pci/drm/radeon_state.c b/sys/dev/pci/drm/radeon_state.c
index f6f8f8044d3..e5e99517470 100644
--- a/sys/dev/pci/drm/radeon_state.c
+++ b/sys/dev/pci/drm/radeon_state.c
@@ -2184,12 +2184,12 @@ radeon_cp_cmdbuf(struct drm_device *dev, void *data,
*/
orig_bufsz = cmdbuf->bufsz;
if (orig_bufsz != 0) {
- kbuf = drm_alloc(cmdbuf->bufsz, DRM_MEM_DRIVER);
+ kbuf = drm_alloc(cmdbuf->bufsz);
if (kbuf == NULL)
return ENOMEM;
if (DRM_COPY_FROM_USER(kbuf, (void __user *)cmdbuf->buf,
cmdbuf->bufsz)) {
- drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
+ drm_free(kbuf);
return EFAULT;
}
cmdbuf->buf = kbuf;
@@ -2202,7 +2202,7 @@ radeon_cp_cmdbuf(struct drm_device *dev, void *data,
temp = r300_do_cp_cmdbuf(dev, file_priv, cmdbuf);
if (orig_bufsz != 0)
- drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
+ drm_free(kbuf);
return temp;
}
@@ -2309,7 +2309,7 @@ radeon_cp_cmdbuf(struct drm_device *dev, void *data,
}
if (orig_bufsz != 0)
- drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
+ drm_free(kbuf);
DRM_DEBUG("DONE\n");
COMMIT_RING();
@@ -2317,7 +2317,7 @@ radeon_cp_cmdbuf(struct drm_device *dev, void *data,
err:
if (orig_bufsz != 0)
- drm_free(kbuf, orig_bufsz, DRM_MEM_DRIVER);
+ drm_free(kbuf);
return EINVAL;
}
diff --git a/sys/dev/pci/drm/savage_bci.c b/sys/dev/pci/drm/savage_bci.c
index 58c9b07a377..d0a0e4bb775 100644
--- a/sys/dev/pci/drm/savage_bci.c
+++ b/sys/dev/pci/drm/savage_bci.c
@@ -298,8 +298,7 @@ static int savage_dma_init(drm_savage_private_t *dev_priv)
dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
(SAVAGE_DMA_PAGE_SIZE*4);
- dev_priv->dma_pages = drm_calloc(sizeof(drm_savage_dma_page_t),
- dev_priv->nr_dma_pages, DRM_MEM_DRIVER);
+ dev_priv->dma_pages = drm_calloc(1, sizeof(*dev_priv->dma_pages));
if (dev_priv->dma_pages == NULL)
return ENOMEM;
@@ -735,8 +734,7 @@ static int savage_do_init_bci(struct drm_device *dev, drm_savage_init_t *init)
dev_priv->fake_dma.offset = 0;
dev_priv->fake_dma.size = SAVAGE_FAKE_DMA_SIZE;
dev_priv->fake_dma.type = _DRM_SHM;
- dev_priv->fake_dma.handle = drm_alloc(SAVAGE_FAKE_DMA_SIZE,
- DRM_MEM_DRIVER);
+ dev_priv->fake_dma.handle = drm_alloc(SAVAGE_FAKE_DMA_SIZE);
if (!dev_priv->fake_dma.handle) {
DRM_ERROR("could not allocate faked DMA buffer!\n");
savage_do_cleanup_bci(dev);
@@ -836,8 +834,7 @@ static int savage_do_cleanup_bci(struct drm_device *dev)
if (dev_priv->cmd_dma == &dev_priv->fake_dma) {
if (dev_priv->fake_dma.handle)
- drm_free(dev_priv->fake_dma.handle,
- SAVAGE_FAKE_DMA_SIZE, DRM_MEM_DRIVER);
+ drm_free(dev_priv->fake_dma.handle);
} else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle &&
dev_priv->cmd_dma->type == _DRM_AGP &&
dev_priv->dma_type == SAVAGE_DMA_AGP)
@@ -853,9 +850,7 @@ static int savage_do_cleanup_bci(struct drm_device *dev)
}
if (dev_priv->dma_pages)
- drm_free(dev_priv->dma_pages,
- sizeof(drm_savage_dma_page_t)*dev_priv->nr_dma_pages,
- DRM_MEM_DRIVER);
+ drm_free(dev_priv->dma_pages);
return 0;
}
diff --git a/sys/dev/pci/drm/savage_state.c b/sys/dev/pci/drm/savage_state.c
index 024cc46370e..25e1aeb6005 100644
--- a/sys/dev/pci/drm/savage_state.c
+++ b/sys/dev/pci/drm/savage_state.c
@@ -987,20 +987,20 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
* for locking on FreeBSD.
*/
if (cmdbuf->size) {
- kcmd_addr = drm_calloc(cmdbuf->size, 8, DRM_MEM_DRIVER);
+ kcmd_addr = drm_calloc(cmdbuf->size, 8);
if (kcmd_addr == NULL)
return ENOMEM;
if (DRM_COPY_FROM_USER(kcmd_addr, cmdbuf->cmd_addr,
cmdbuf->size * 8))
{
- drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER);
+ drm_free(kcmd_addr);
return EFAULT;
}
cmdbuf->cmd_addr = kcmd_addr;
}
if (cmdbuf->vb_size) {
- kvb_addr = drm_alloc(cmdbuf->vb_size, DRM_MEM_DRIVER);
+ kvb_addr = drm_alloc(cmdbuf->vb_size);
if (kvb_addr == NULL) {
ret = ENOMEM;
goto done;
@@ -1014,8 +1014,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
cmdbuf->vb_addr = kvb_addr;
}
if (cmdbuf->nbox) {
- kbox_addr = drm_calloc(cmdbuf->nbox,
- sizeof(struct drm_clip_rect), DRM_MEM_DRIVER);
+ kbox_addr = drm_calloc(cmdbuf->nbox, sizeof(*kbox_addr));
if (kbox_addr == NULL) {
ret = ENOMEM;
goto done;
@@ -1156,10 +1155,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
done:
/* If we didn't need to allocate them, these'll be NULL */
- drm_free(kcmd_addr, cmdbuf->size * 8, DRM_MEM_DRIVER);
- drm_free(kvb_addr, cmdbuf->vb_size, DRM_MEM_DRIVER);
- drm_free(kbox_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect),
- DRM_MEM_DRIVER);
+ drm_free(kcmd_addr);
+ drm_free(kvb_addr);
+ drm_free(kbox_addr);
return ret;
}
diff --git a/sys/dev/pci/drm/sis_ds.c b/sys/dev/pci/drm/sis_ds.c
index 2e485d48294..959ddd96927 100644
--- a/sys/dev/pci/drm/sis_ds.c
+++ b/sys/dev/pci/drm/sis_ds.c
@@ -41,7 +41,7 @@ set_t *setInit(void)
int i;
set_t *set;
- set = (set_t *) drm_alloc(sizeof(set_t), DRM_MEM_DRIVER);
+ set = drm_alloc(sizeof(*set));
if (set != NULL) {
for (i = 0; i < SET_SIZE; i++) {
set->list[i].free_next = i + 1;
@@ -127,7 +127,7 @@ int setNext(set_t * set, ITEM_TYPE * item)
int setDestroy(set_t * set)
{
- drm_free(set, sizeof(set_t), DRM_MEM_DRIVER);
+ drm_free(set);
return 1;
}
@@ -165,7 +165,7 @@ memHeap_t *mmInit(int ofs, int size)
if (size <= 0)
return NULL;
- blocks = (TMemBlock *) drm_calloc(1, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ blocks = drm_calloc(1, sizeof(*blocks));
if (blocks != NULL) {
blocks->ofs = ofs;
blocks->size = size;
@@ -201,8 +201,7 @@ static TMemBlock *SliceBlock(TMemBlock * p,
/* break left */
if (startofs > p->ofs) {
- newblock = (TMemBlock *) drm_calloc(1, sizeof(TMemBlock),
- DRM_MEM_DRIVER);
+ newblock = drm_calloc(1, sizeof(*newblock));
newblock->ofs = startofs;
newblock->size = p->size - (startofs - p->ofs);
newblock->free = 1;
@@ -214,8 +213,7 @@ static TMemBlock *SliceBlock(TMemBlock * p,
/* break right */
if (size < p->size) {
- newblock = (TMemBlock *) drm_calloc(1, sizeof(TMemBlock),
- DRM_MEM_DRIVER);
+ newblock = drm_calloc(1, sizeof(*newblock));
newblock->ofs = startofs + size;
newblock->size = p->size - size;
newblock->free = 1;
@@ -267,7 +265,7 @@ static __inline__ int Join2Blocks(TMemBlock * p)
TMemBlock *q = p->next;
p->size += q->size;
p->next = q->next;
- drm_free(q, sizeof(TMemBlock), DRM_MEM_DRIVER);
+ drm_free(q);
return 1;
}
return 0;