Apply a light paddling with the knf stick. No binary change.
authoroga <oga@openbsd.org>
Sat, 16 Aug 2008 01:53:05 +0000 (01:53 +0000)
committeroga <oga@openbsd.org>
Sat, 16 Aug 2008 01:53:05 +0000 (01:53 +0000)
14 files changed:
sys/dev/pci/drm/drmP.h
sys/dev/pci/drm/drm_agpsupport.c
sys/dev/pci/drm/drm_bufs.c
sys/dev/pci/drm/drm_context.c
sys/dev/pci/drm/drm_dma.c
sys/dev/pci/drm/drm_drawable.c
sys/dev/pci/drm/drm_drv.c
sys/dev/pci/drm/drm_fops.c
sys/dev/pci/drm/drm_ioctl.c
sys/dev/pci/drm/drm_irq.c
sys/dev/pci/drm/drm_lock.c
sys/dev/pci/drm/drm_memory.c
sys/dev/pci/drm/drm_pci.c
sys/dev/pci/drm/drm_scatter.c

index e073634..ee0cd62 100644 (file)
@@ -270,7 +270,7 @@ do {                                                                        \
 
 /* Returns -errno to shared code */
 #define DRM_WAIT_ON( ret, queue, timeout, condition )          \
-ret = 0;                                                               \
+ret = 0;                                                       \
 while ( ret == 0 ) {                                           \
        DRM_UNLOCK();                                           \
        DRM_SPINLOCK(&dev->irq_lock);                           \
index 2289986..ea8a5c1 100644 (file)
@@ -51,8 +51,8 @@ drm_device_is_agp(struct drm_device *dev)
 {
        if (dev->driver.device_is_agp != NULL) {
                int ret;
-
-               /* device_is_agp returns a tristate, 0 = not AGP, 1 = definitely
+               /*
+                * device_is_agp returns a tristate, 0 = not AGP, 1 = definitely
                 * AGP, 2 = fall back to PCI capability
                 */
                ret = (*dev->driver.device_is_agp)(dev);
@@ -77,19 +77,19 @@ drm_agp_info(struct drm_device * dev, drm_agp_info_t *info)
        if (!dev->agp || !dev->agp->acquired)
                return EINVAL;
 
-       kern                   = &dev->agp->info;
+       kern = &dev->agp->info;
 #ifndef DRM_NO_AGP
        agp_get_info(dev->agp->agpdev, kern);
 #endif
        info->agp_version_major = 1;
        info->agp_version_minor = 0;
-       info->mode              = kern->ai_mode;
-       info->aperture_base     = kern->ai_aperture_base;
-       info->aperture_size     = kern->ai_aperture_size;
-       info->memory_allowed    = kern->ai_memory_allowed;
-       info->memory_used       = kern->ai_memory_used;
-       info->id_vendor         = kern->ai_devid & 0xffff;
-       info->id_device         = kern->ai_devid >> 16;
+       info->mode = kern->ai_mode;
+       info->aperture_base = kern->ai_aperture_base;
+       info->aperture_size = kern->ai_aperture_size;
+       info->memory_allowed = kern->ai_memory_allowed;
+       info->memory_used = kern->ai_memory_used;
+       info->id_vendor = kern->ai_devid & 0xffff;
+       info->id_device = kern->ai_devid >> 16;
 
        return 0;
 }
@@ -105,7 +105,7 @@ drm_agp_info_ioctl(struct drm_device *dev, void *data,
        if (err != 0)
                return err;
 
-       *(drm_agp_info_t *) data = info;
+       *(drm_agp_info_t *)data = info;
        return 0;
 }
 
@@ -197,7 +197,7 @@ drm_agp_alloc(struct drm_device *dev, drm_agp_buffer_t *request)
                return ENOMEM;
 
        pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
-       type = (u_int32_t) request->type;
+       type = (u_int32_t)request->type;
 
        DRM_UNLOCK();
        handle = drm_agp_allocate_memory(pages, type);
@@ -245,7 +245,8 @@ drm_agp_lookup_entry(struct drm_device *dev, void *handle)
        struct drm_agp_mem *entry;
 
        TAILQ_FOREACH(entry, &dev->agp->memory, link) {
-               if (entry->handle == handle) return entry;
+               if (entry->handle == handle)
+                       return entry;
        }
        return NULL;
 }
@@ -365,7 +366,7 @@ drm_agp_free_ioctl(struct drm_device *dev, void *data,
        drm_agp_buffer_t request;
        int retcode;
 
-       request = *(drm_agp_buffer_t *) data;
+       request = *(drm_agp_buffer_t *)data;
 
        DRM_LOCK();
        retcode = drm_agp_free(dev, &request);
index fdaa063..60c0cd4 100644 (file)
@@ -52,9 +52,10 @@ drm_order(unsigned long size)
        int order;
        unsigned long tmp;
 
-       for ( order = 0, tmp = size ; tmp >>= 1 ; ++order );
+       for (order = 0, tmp = size; tmp >>= 1; ++order)
+               ;
 
-       if ( size & ~(1 << order) )
+       if (size & ~(1 << order))
                ++order;
 
        return order;
@@ -140,7 +141,8 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
        DRM_DEBUG("offset = 0x%08lx, size = 0x%08lx, type = %d\n", offset,
            size, type);
 
-       /* Check if this is just another version of a kernel-allocated map, and
+       /*
+        * Check if this is just another version of a kernel-allocated map, and
         * just hand that back if so.
         */
        if (type == _DRM_REGISTERS || type == _DRM_FRAME_BUFFER ||
@@ -161,7 +163,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
         * initialization necessary.
         */
        map = drm_calloc(1, sizeof(*map), DRM_MEM_MAPS);
-       if ( !map ) {
+       if (map == NULL) {
                DRM_LOCK();
                return ENOMEM;
        }
@@ -187,10 +189,10 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
                return ENOMEM;
        }
 
-       switch ( map->type ) {
+       switch (map->type) {
        case _DRM_REGISTERS:
                map->handle = drm_ioremap(dev, map);
-               if (!map->handle) {
+               if (map->handle == NULL) {
                        DRM_LOCK();
                        return EINVAL;
                }
@@ -242,7 +244,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
 #endif
                break;
        case _DRM_SCATTER_GATHER:
-               if (!dev->sg) {
+               if (dev->sg == NULL) {
                        drm_free(map, sizeof(*map), DRM_MEM_MAPS);
                        DRM_LOCK();
                        return EINVAL;
@@ -268,8 +270,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
                }
                map->handle = map->dmah->vaddr;
                map->offset = map->dmah->busaddr;
-               if (map->type == _DRM_SHM &&
-                   map->flags & _DRM_CONTAINS_LOCK) {
+               if (map->type == _DRM_SHM && map->flags & _DRM_CONTAINS_LOCK) {
                        DRM_LOCK();
                        /* Prevent a 2nd X Server from creating a 2nd lock */
                        if (dev->lock.hw_lock != NULL) {
@@ -325,7 +326,7 @@ drm_addmap_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
        request->size = map->size;
        request->type = map->type;
        request->flags = map->flags;
-       request->mtrr   = map->mtrr;
+       request->mtrr = map->mtrr;
        request->handle = map->handle;
 
        request->handle = (void *)map->mm->start;
@@ -409,9 +410,8 @@ drm_cleanup_buf_error(struct drm_device *dev, drm_buf_entry_t *entry)
        int i;
 
        if (entry->seg_count) {
-               for (i = 0; i < entry->seg_count; i++) {
+               for (i = 0; i < entry->seg_count; i++)
                        drm_pci_free(dev, entry->seglist[i]);
-               }
                drm_free(entry->seglist, entry->seg_count *
                    sizeof(*entry->seglist), DRM_MEM_BUFS);
 
@@ -464,13 +464,13 @@ drm_do_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request)
        byte_count = 0;
        agp_offset = dev->agp->base + request->agp_start;
 
-       DRM_DEBUG( "count:      %d\n",  count );
-       DRM_DEBUG( "order:      %d\n",  order );
-       DRM_DEBUG( "size:       %d\n",  size );
-       DRM_DEBUG( "agp_offset: 0x%lx\n", agp_offset );
-       DRM_DEBUG( "alignment:  %d\n",  alignment );
-       DRM_DEBUG( "page_order: %d\n",  page_order );
-       DRM_DEBUG( "total:      %d\n",  total );
+       DRM_DEBUG("count:      %d\n",  count);
+       DRM_DEBUG("order:      %d\n",  order);
+       DRM_DEBUG("size:       %d\n",  size);
+       DRM_DEBUG("agp_offset: 0x%lx\n", agp_offset);
+       DRM_DEBUG("alignment:  %d\n",  alignment);
+       DRM_DEBUG("page_order: %d\n",  page_order);
+       DRM_DEBUG("total:      %d\n",  total);
 
        /* Make sure buffers are located in AGP memory that we own */
 
@@ -498,16 +498,15 @@ drm_do_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request)
 
        entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
            DRM_MEM_BUFS);
-       if ( !entry->buflist ) {
+       if (entry->buflist == NULL)
                return ENOMEM;
-       }
 
        entry->buf_size = size;
        entry->page_order = page_order;
 
        offset = 0;
 
-       while ( entry->buf_count < count ) {
+       while (entry->buf_count < count) {
                buf = &entry->buflist[entry->buf_count];
                buf->idx = dma->buf_count + entry->buf_count;
                buf->total = alignment;
@@ -536,7 +535,7 @@ drm_do_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request)
                byte_count += PAGE_SIZE << page_order;
        }
 
-       DRM_DEBUG( "byte_count: %d\n", byte_count );
+       DRM_DEBUG("byte_count: %d\n", byte_count);
 
        /* OpenBSD lacks realloc in kernel */
        temp_buflist = drm_realloc(dma->buflist,
@@ -549,15 +548,14 @@ drm_do_addbufs_agp(struct drm_device *dev, drm_buf_desc_t *request)
        }
        dma->buflist = temp_buflist;
 
-       for ( i = 0 ; i < entry->buf_count ; i++ ) {
+       for (i = 0; i < entry->buf_count; i++)
                dma->buflist[i + dma->buf_count] = &entry->buflist[i];
-       }
 
        dma->buf_count += entry->buf_count;
        dma->byte_count += byte_count;
 
-       DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count );
-       DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count );
+       DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
+       DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
 
        request->count = entry->buf_count;
        request->size = size;
@@ -590,8 +588,8 @@ drm_do_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
        order = drm_order(request->size);
        size = 1 << order;
 
-       DRM_DEBUG( "count=%d, size=%d (%d), order=%d\n",
-           request->count, request->size, size, order );
+       DRM_DEBUG("count=%d, size=%d (%d), order=%d\n",
+           request->count, request->size, size, order);
 
        alignment = (request->flags & _DRM_PAGE_ALIGN)
            ? round_page(size) : size;
@@ -625,15 +623,15 @@ drm_do_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
        memcpy(temp_pagelist, dma->pagelist, dma->page_count * 
            sizeof(*dma->pagelist));
 
-       DRM_DEBUG( "pagelist: %d entries\n",
-           dma->page_count + (count << page_order) );
+       DRM_DEBUG("pagelist: %d entries\n",
+           dma->page_count + (count << page_order));
 
        entry->buf_size = size;
        entry->page_order = page_order;
        byte_count = 0;
        page_count = 0;
 
-       while ( entry->buf_count < count ) {
+       while (entry->buf_count < count) {
                drm_dma_handle_t *dmah = drm_pci_alloc(dev, size, alignment,
                    0xfffffffful);
                if (dmah == NULL) {
@@ -648,33 +646,33 @@ drm_do_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
                }
 
                entry->seglist[entry->seg_count++] = dmah;
-               for ( i = 0 ; i < (1 << page_order) ; i++ ) {
-                       DRM_DEBUG( "page %d @ %p\n",
+               for (i = 0; i < (1 << page_order); i++) {
+                       DRM_DEBUG("page %d @ %p\n",
                            dma->page_count + page_count,
-                           (char *)dmah->vaddr + PAGE_SIZE * i );
+                           (char *)dmah->vaddr + PAGE_SIZE * i);
                        temp_pagelist[dma->page_count + page_count++] = 
                            (long)dmah->vaddr + PAGE_SIZE * i;
                }
-               for ( offset = 0 ;
-                   offset + size <= total && entry->buf_count < count ;
-                   offset += alignment, ++entry->buf_count ) {
-                       buf          = &entry->buflist[entry->buf_count];
-                       buf->idx     = dma->buf_count + entry->buf_count;
-                       buf->total   = alignment;
-                       buf->order   = order;
-                       buf->used    = 0;
-                       buf->offset  = (dma->byte_count + byte_count + offset);
+               for (offset = 0;
+                   offset + size <= total && entry->buf_count < count;
+                   offset += alignment, ++entry->buf_count) {
+                       buf = &entry->buflist[entry->buf_count];
+                       buf->idx = dma->buf_count + entry->buf_count;
+                       buf->total = alignment;
+                       buf->order = order;
+                       buf->used = 0;
+                       buf->offset = (dma->byte_count + byte_count + offset);
                        buf->address = ((char *)dmah->vaddr + offset);
                        buf->bus_address = dmah->busaddr + offset;
-                       buf->next    = NULL;
+                       buf->next = NULL;
                        buf->pending = 0;
-                       buf->file_priv    = NULL;
+                       buf->file_priv = NULL;
 
                        buf->dev_priv_size = dev->driver.buf_priv_size;
                        buf->dev_private = drm_calloc(1, buf->dev_priv_size,
                            DRM_MEM_BUFS);
                        if (buf->dev_private == NULL) {
-                               /* Set count correctly so we free the proper amount. */
+                               /* Set count so we free the proper amount. */
                                entry->buf_count = count;
                                entry->seg_count = count;
                                drm_cleanup_buf_error(dev, entry);
@@ -685,13 +683,13 @@ drm_do_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
                                return ENOMEM;
                        }
 
-                       DRM_DEBUG( "buffer %d @ %p\n",
-                           entry->buf_count, buf->address );
+                       DRM_DEBUG("buffer %d @ %p\n",
+                           entry->buf_count, buf->address);
                }
                byte_count += PAGE_SIZE << page_order;
        }
 
-       temp_buflist = drm_realloc( dma->buflist,
+       temp_buflist = drm_realloc(dma->buflist,
            dma->buf_count * sizeof(*dma->buflist),
            (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
        if (temp_buflist == NULL) {
@@ -704,9 +702,8 @@ drm_do_addbufs_pci(struct drm_device *dev, drm_buf_desc_t *request)
        }
        dma->buflist = temp_buflist;
 
-       for ( i = 0 ; i < entry->buf_count ; i++ ) {
+       for (i = 0; i < entry->buf_count; i++)
                dma->buflist[i + dma->buf_count] = &entry->buflist[i];
-       }
 
        /* No allocations failed, so now we can replace the orginal pagelist
         * with the new one.
@@ -757,13 +754,13 @@ drm_do_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request)
        byte_count = 0;
        agp_offset = request->agp_start;
 
-       DRM_DEBUG( "count:      %d\n",  count );
-       DRM_DEBUG( "order:      %d\n",  order );
-       DRM_DEBUG( "size:       %d\n",  size );
-       DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
-       DRM_DEBUG( "alignment:  %d\n",  alignment );
-       DRM_DEBUG( "page_order: %d\n",  page_order );
-       DRM_DEBUG( "total:      %d\n",  total );
+       DRM_DEBUG("count:      %d\n",  count);
+       DRM_DEBUG("order:      %d\n",  order);
+       DRM_DEBUG("size:       %d\n",  size);
+       DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+       DRM_DEBUG("alignment:  %d\n",  alignment);
+       DRM_DEBUG("page_order: %d\n",  page_order);
+       DRM_DEBUG("total:      %d\n",  total);
 
        entry = &dma->bufs[order];
 
@@ -777,7 +774,7 @@ drm_do_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request)
 
        offset = 0;
 
-       while ( entry->buf_count < count ) {
+       while (entry->buf_count < count) {
                buf = &entry->buflist[entry->buf_count];
                buf->idx = dma->buf_count + entry->buf_count;
                buf->total = alignment;
@@ -801,15 +798,14 @@ drm_do_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request)
                        return ENOMEM;
                }
 
-               DRM_DEBUG( "buffer %d @ %p\n",
-                   entry->buf_count, buf->address );
+               DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
 
                offset += alignment;
                entry->buf_count++;
                byte_count += PAGE_SIZE << page_order;
        }
 
-       DRM_DEBUG( "byte_count: %d\n", byte_count );
+       DRM_DEBUG("byte_count: %d\n", byte_count);
 
        temp_buflist = drm_realloc(dma->buflist, 
            dma->buf_count * sizeof(*dma->buflist),
@@ -821,15 +817,14 @@ drm_do_addbufs_sg(struct drm_device *dev, drm_buf_desc_t *request)
        }
        dma->buflist = temp_buflist;
 
-       for ( i = 0 ; i < entry->buf_count ; i++ ) {
+       for (i = 0; i < entry->buf_count; i++)
                dma->buflist[i + dma->buf_count] = &entry->buflist[i];
-       }
 
        dma->buf_count += entry->buf_count;
        dma->byte_count += byte_count;
 
-       DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count );
-       DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count );
+       DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
+       DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
 
        request->count = entry->buf_count;
        request->size = size;
@@ -967,34 +962,35 @@ drm_infobufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
        ++dev->buf_use;         /* Can't allocate more after this call */
        DRM_SPINUNLOCK(&dev->dma_lock);
 
-       for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
-               if ( dma->bufs[i].buf_count ) ++count;
+       for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
+               if (dma->bufs[i].buf_count)
+                   ++count;
        }
 
-       DRM_DEBUG( "count = %d\n", count );
+       DRM_DEBUG("count = %d\n", count);
 
-       if ( request->count >= count ) {
-               for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
-                       if ( dma->bufs[i].buf_count ) {
+       if (request->count >= count) {
+               for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
+                       if (dma->bufs[i].buf_count) {
                                drm_buf_desc_t from;
 
                                from.count = dma->bufs[i].buf_count;
                                from.size = dma->bufs[i].buf_size;
                                from.low_mark = dma->bufs[i].freelist.low_mark;
-                               from.high_mark = dma->bufs[i].freelist.high_mark;
+                               from.high_mark =
+                                   dma->bufs[i].freelist.high_mark;
 
-                               if (DRM_COPY_TO_USER(&request->list[count], &from,
-                                   sizeof(drm_buf_desc_t)) != 0) {
+                               if (DRM_COPY_TO_USER(&request->list[count],
+                                   &from, sizeof(drm_buf_desc_t)) != 0) {
                                        retcode = EFAULT;
                                        break;
                                }
 
-                               DRM_DEBUG( "%d %d %d %d %d\n",
-                                   i,
+                               DRM_DEBUG("%d %d %d %d %d\n", i,
                                    dma->bufs[i].buf_count,
                                    dma->bufs[i].buf_size,
                                    dma->bufs[i].freelist.low_mark,
-                                   dma->bufs[i].freelist.high_mark );
+                                   dma->bufs[i].freelist.high_mark);
                                ++count;
                        }
                }
@@ -1011,8 +1007,8 @@ drm_markbufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
        drm_buf_desc_t *request = data;
        int order;
 
-       DRM_DEBUG( "%d, %d, %d\n",
-           request->size, request->low_mark, request->high_mark );
+       DRM_DEBUG("%d, %d, %d\n", request->size, request->low_mark,
+           request->high_mark);
        
 
        order = drm_order(request->size);       
@@ -1045,22 +1041,22 @@ drm_freebufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
        drm_buf_t *buf;
        int retcode = 0;
 
-       DRM_DEBUG( "%d\n", request->count );
+       DRM_DEBUG("%d\n", request->count);
        
        DRM_SPINLOCK(&dev->dma_lock);
-       for ( i = 0 ; i < request->count ; i++ ) {
+       for (i = 0; i < request->count; i++) {
                if (DRM_COPY_FROM_USER(&idx, &request->list[i], sizeof(idx))) {
                        retcode = EFAULT;
                        break;
                }
-               if ( idx < 0 || idx >= dma->buf_count ) {
-                       DRM_ERROR( "Index %d (of %d max)\n",
-                           idx, dma->buf_count - 1 );
+               if (idx < 0 || idx >= dma->buf_count) {
+                       DRM_ERROR("Index %d (of %d max)\n", idx,
+                           dma->buf_count - 1);
                        retcode = EINVAL;
                        break;
                }
                buf = dma->buflist[idx];
-               if ( buf->file_priv != file_priv ) {
+               if (buf->file_priv != file_priv) {
                        DRM_ERROR("Process %d freeing buffer not owned\n",
                            DRM_CURRENTPID);
                        retcode = EINVAL;
@@ -1128,7 +1124,7 @@ drm_mapbufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
 
        request->virtual = (void *)vaddr;
 
-       for ( i = 0 ; i < dma->buf_count ; i++ ) {
+       for (i = 0; i < dma->buf_count; i++) {
                if (DRM_COPY_TO_USER(&request->list[i].idx,
                    &dma->buflist[i]->idx, sizeof(request->list[0].idx))) {
                        retcode = EFAULT;
@@ -1155,7 +1151,7 @@ drm_mapbufs(struct drm_device *dev, void *data, struct drm_file *file_priv)
  done:
        request->count = dma->buf_count;
 
-       DRM_DEBUG( "%d buffers, retcode = %d\n", request->count, retcode );
+       DRM_DEBUG("%d buffers, retcode = %d\n", request->count, retcode);
 
        return retcode;
 }
index 1441318..beb363f 100644 (file)
@@ -63,7 +63,7 @@ drm_ctxbitmap_next(struct drm_device *dev)
                return -1;
 
        DRM_LOCK();
-       bit = find_first_zero_bit( dev->ctx_bitmap, DRM_MAX_CTXBITMAP );
+       bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
        if (bit >= DRM_MAX_CTXBITMAP) {
                DRM_UNLOCK();
                return -1;
@@ -85,16 +85,16 @@ drm_ctxbitmap_init(struct drm_device *dev)
 
        DRM_LOCK();
        dev->ctx_bitmap = drm_calloc(1, PAGE_SIZE, DRM_MEM_CTXBITMAP);
-       if ( dev->ctx_bitmap == NULL ) {
+       if (dev->ctx_bitmap == NULL) {
                DRM_UNLOCK();
                return ENOMEM;
        }
        dev->max_context = -1;
        DRM_UNLOCK();
 
-       for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
+       for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
                temp = drm_ctxbitmap_next(dev);
-               DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
+               DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp);
        }
 
        return 0;
@@ -115,12 +115,12 @@ drm_resctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
        drm_ctx_t ctx;
        int i;
 
-       if ( res->count >= DRM_RESERVED_CONTEXTS ) {
+       if (res->count >= DRM_RESERVED_CONTEXTS) {
                bzero(&ctx, sizeof(ctx));
-               for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
+               for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
                        ctx.handle = i;
-                       if ( DRM_COPY_TO_USER( &res->contexts[i],
-                           &ctx, sizeof(ctx) ) )
+                       if (DRM_COPY_TO_USER(&res->contexts[i],
+                           &ctx, sizeof(ctx)))
                                return EFAULT;
                }
        }
@@ -135,13 +135,13 @@ drm_addctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
        drm_ctx_t *ctx = data;
 
        ctx->handle = drm_ctxbitmap_next(dev);
-       if ( ctx->handle == DRM_KERNEL_CONTEXT ) {
+       if (ctx->handle == DRM_KERNEL_CONTEXT) {
                /* Skip kernel's context and get a new one. */
                ctx->handle = drm_ctxbitmap_next(dev);
        }
-       DRM_DEBUG( "%d\n", ctx->handle );
-       if ( ctx->handle == -1 ) {
-               DRM_DEBUG( "Not enough free contexts.\n" );
+       DRM_DEBUG("%d\n", ctx->handle);
+       if (ctx->handle == -1) {
+               DRM_DEBUG("Not enough free contexts.\n");
                /* Should this return -EBUSY instead? */
                return ENOMEM;
        }
@@ -171,8 +171,8 @@ drm_rmctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
        drm_ctx_t *ctx = data;
 
-       DRM_DEBUG( "%d\n", ctx->handle );
-       if ( ctx->handle != DRM_KERNEL_CONTEXT ) {
+       DRM_DEBUG("%d\n", ctx->handle);
+       if (ctx->handle != DRM_KERNEL_CONTEXT) {
                if (dev->driver.context_dtor) {
                        DRM_LOCK();
                        dev->driver.context_dtor(dev, ctx->handle);
index 81c5636..4922a03 100644 (file)
@@ -64,9 +64,7 @@ drm_dma_takedown(struct drm_device *dev)
        for (i = 0; i <= DRM_MAX_ORDER; i++) {
                if (dma->bufs[i].seg_count) {
                        DRM_DEBUG("order %d: buf_count = %d,"
-                           " seg_count = %d\n",
-                           i,
-                           dma->bufs[i].buf_count,
+                           " seg_count = %d\n", i, dma->bufs[i].buf_count,
                            dma->bufs[i].seg_count);
                        for (j = 0; j < dma->bufs[i].seg_count; j++) {
                                drm_pci_free(dev, dma->bufs[i].seglist[j]);
@@ -105,7 +103,8 @@ drm_dma_takedown(struct drm_device *dev)
 void
 drm_free_buffer(struct drm_device *dev, drm_buf_t *buf)
 {
-       if (!buf) return;
+       if (buf == NULL)
+               return;
 
        buf->pending = 0;
        buf->file_priv= NULL;
@@ -118,7 +117,8 @@ drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv)
        drm_device_dma_t *dma = dev->dma;
        int i;
 
-       if (!dma) return;
+       if (dma == NULL)
+               return;
        for (i = 0; i < dma->buf_count; i++) {
                if (dma->buflist[i]->file_priv == file_priv) {
                        switch (dma->buflist[i]->list) {
index 15f4ba5..be4444b 100644 (file)
@@ -48,9 +48,9 @@ RB_PROTOTYPE(drawable_tree, bsd_drm_drawable_info, tree,
     drm_drawable_compare);
 
 struct bsd_drm_drawable_info {
-       struct drm_drawable_info info;
-       unsigned int handle;
-       RB_ENTRY(bsd_drm_drawable_info) tree;
+       struct drm_drawable_info        info;
+       unsigned int                    handle;
+       RB_ENTRY(bsd_drm_drawable_info) tree;
 };
 
 int
@@ -157,8 +157,8 @@ drm_update_draw(struct drm_device *dev, void *data, struct drm_file *file_priv)
                        struct drm_clip_rect *rects;
 
                        DRM_SPINUNLOCK(&dev->drw_lock);
-                       rects = drm_calloc(update->num, 
-                           sizeof(*info->rects), DRM_MEM_DRAWABLE);
+                       rects = drm_calloc(update->num, sizeof(*info->rects),
+                           DRM_MEM_DRAWABLE);
                        DRM_SPINLOCK(&dev->drw_lock);
                        if (rects == NULL) {
                                ret = ENOMEM;
@@ -188,8 +188,8 @@ drm_drawable_free(struct drm_device *dev, struct bsd_drm_drawable_info *draw)
                return;
        RB_REMOVE(drawable_tree, &dev->drw_head, draw);
        DRM_SPINUNLOCK(&dev->drw_lock);
-       drm_free(draw->info.rects,
-           sizeof(*draw->info.rects) * draw->info.num_rects, DRM_MEM_DRAWABLE);
+       drm_free(draw->info.rects, sizeof(*draw->info.rects) *
+           draw->info.num_rects, DRM_MEM_DRAWABLE);
        drm_free(draw, sizeof(*draw), DRM_MEM_DRAWABLE);
        DRM_SPINLOCK(&dev->drw_lock);
 }
@@ -200,13 +200,10 @@ drm_drawable_free_all(struct drm_device *dev)
        struct bsd_drm_drawable_info *draw, *nxt;
 
        DRM_SPINLOCK(&dev->drw_lock);
-
        for (draw = RB_MIN(drawable_tree, &dev->drw_head); draw != NULL;
            draw = nxt) {
                nxt = RB_NEXT(drawable_tree, &dev->drw_head, draw);
                drm_drawable_free(dev, draw);
-
        }
        DRM_SPINUNLOCK(&dev->drw_lock);
-
 }
index fff4dfb..476fd99 100644 (file)
  */
 
 #include <sys/limits.h>
+#include <sys/ttycom.h> /* for TIOCSGRP */
+
 #include "drmP.h"
 #include "drm.h"
 #include "drm_sarea.h"
-#include <sys/ttycom.h> /* for TIOCSGRP */
 
 #ifdef DRM_DEBUG_DEFAULT_ON
 int drm_debug_flag = 1;
@@ -56,62 +57,89 @@ static drm_ioctl_desc_t               drm_ioctls[256] = {
        DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
-       DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid,
+           DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, 0),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0),
-       DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, DRM_MASTER|DRM_ROOT_ONLY),
-
-       DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-
-       DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion,
+           DRM_MASTER|DRM_ROOT_ONLY),
+
+       DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+       DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_noop,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_noop, DRM_AUTH),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH),
-       DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_noop,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_noop,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
        DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH),
        DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH),
        DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER),
        DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
        DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
        DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
        DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma, DRM_AUTH),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
        DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH),
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-
-       DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-       DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+       DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
        DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0),
        DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0),
-       DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+       DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw,
+           DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 };
 
 struct drm_device *drm_units[DRM_MAXUNITS];
@@ -125,15 +153,16 @@ drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist)
        drm_pci_id_list_t *id_entry;
 
        /* first make sure there is place for the device */
-       for(unit=0; unit<DRM_MAXUNITS; unit++)
-               if(drm_units[unit] == NULL) break;
-       if(unit == DRM_MAXUNITS) return 0;
+       for (unit=0; unit<DRM_MAXUNITS; unit++)
+               if (drm_units[unit] == NULL)
+                       break;
+       if (unit == DRM_MAXUNITS)
+               return 0;
 
        id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
            PCI_PRODUCT(pa->pa_id), idlist);
-       if (id_entry != NULL) {
+       if (id_entry != NULL)
                return 1;
-       }
 
        return 0;
 }
@@ -146,16 +175,18 @@ drm_attach(struct device *parent, struct device *kdev,
        struct drm_device *dev;
        drm_pci_id_list_t *id_entry;
 
-       if(init_units) {
-               for(unit=0; unit<DRM_MAXUNITS;unit++)
+       if (init_units) {
+               for (unit=0; unit<DRM_MAXUNITS; unit++)
                        drm_units[unit] = NULL;
                init_units = 0;
        }
 
 
-        for(unit=0; unit<DRM_MAXUNITS; unit++)
-               if(drm_units[unit] == NULL) break;
-       if(unit == DRM_MAXUNITS) return;
+        for (unit=0; unit<DRM_MAXUNITS; unit++)
+               if (drm_units[unit] == NULL)
+                       break;
+       if (unit == DRM_MAXUNITS)
+               return;
 
        dev = drm_units[unit] = (struct drm_device*)kdev;
        dev->unit = unit;
@@ -210,9 +241,8 @@ drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist)
        
        for (i = 0; idlist[i].vendor != 0; i++) {
                if ((idlist[i].vendor == vendor) &&
-                   (idlist[i].device == device)) {
+                   (idlist[i].device == device))
                        return &idlist[i];
-               }
        }
        return NULL;
 }
@@ -250,8 +280,8 @@ drm_firstopen(struct drm_device *dev)
        dev->types[4] = _DRM_STAT_LOCKS;
        dev->types[5] = _DRM_STAT_UNLOCKS;
 
-       for ( i = 0 ; i < DRM_ARRAY_SIZE(dev->counts) ; i++ )
-               atomic_set( &dev->counts[i], 0 );
+       for (i = 0; i < DRM_ARRAY_SIZE(dev->counts); i++)
+               atomic_set(&dev->counts[i], 0);
 
        dev->magicid = 1;
        SPLAY_INIT(&dev->magiclist);
@@ -262,7 +292,7 @@ drm_firstopen(struct drm_device *dev)
 
        dev->buf_pgid = 0;
 
-       DRM_DEBUG( "\n" );
+       DRM_DEBUG("\n");
 
        return 0;
 }
@@ -275,7 +305,7 @@ drm_lastclose(struct drm_device *dev)
 
        DRM_SPINLOCK_ASSERT(&dev->dev_lock);
 
-       DRM_DEBUG( "\n" );
+       DRM_DEBUG("\n");
 
        if (dev->driver.lastclose != NULL)
                dev->driver.lastclose(dev);
@@ -283,28 +313,28 @@ drm_lastclose(struct drm_device *dev)
        if (dev->irq_enabled)
                drm_irq_uninstall(dev);
 
-       if ( dev->unique ) {
+       if (dev->unique != NULL) {
                drm_free(dev->unique, dev->unique_len + 1,  DRM_MEM_DRIVER);
                dev->unique = NULL;
                dev->unique_len = 0;
        }
 
        drm_drawable_free_all(dev);
-                               /* Clear pid list */
+       /* 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);
        }
 
                                /* Clear AGP information */
-       if ( dev->agp ) {
+       if (dev->agp != NULL) {
                struct drm_agp_mem *entry;
 
                /* Remove AGP resources, but leave dev->agp intact until
                 * drm_unload is called.
                 */
                while ((entry = TAILQ_FIRST(&dev->agp->memory)) != NULL) {
-                       if ( entry->bound )
+                       if (entry->bound)
                                drm_agp_unbind_memory(entry->handle);
                        drm_agp_free_memory(entry->handle);
                        TAILQ_REMOVE(&dev->agp->memory, entry, link);
@@ -330,7 +360,7 @@ drm_lastclose(struct drm_device *dev)
        }
 
        drm_dma_takedown(dev);
-       if ( dev->lock.hw_lock ) {
+       if (dev->lock.hw_lock != NULL) {
                dev->lock.hw_lock = NULL; /* SHM removed */
                dev->lock.file_priv = NULL;
                DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
@@ -344,7 +374,7 @@ drm_load(struct drm_device *dev)
 {
        int retcode;
 
-       DRM_DEBUG( "\n" );
+       DRM_DEBUG("\n");
 
        dev->irq = dev->pa.pa_intrline;
        dev->pci_domain = 0;
@@ -403,11 +433,8 @@ drm_load(struct drm_device *dev)
                DRM_ERROR("Cannot allocate memory for context bitmap.\n");
                goto error;
        }
-       printf(", %d.%d.%d %s\n",
-           dev->driver.major,
-           dev->driver.minor,
-           dev->driver.patchlevel,
-           dev->driver.date);
+       printf(", %d.%d.%d %s\n", dev->driver.major, dev->driver.minor,
+           dev->driver.patchlevel, dev->driver.date);
 
        return 0;
 
@@ -423,7 +450,7 @@ void
 drm_unload(struct drm_device *dev)
 {
 
-       DRM_DEBUG( "\n" );
+       DRM_DEBUG("\n");
 
        drm_ctxbitmap_cleanup(dev);
 
@@ -443,7 +470,7 @@ drm_unload(struct drm_device *dev)
        drm_lastclose(dev);
        DRM_UNLOCK();
 
-       if ( dev->agp ) {
+       if (dev->agp != NULL) {
                drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
                dev->agp = NULL;
        }
@@ -462,7 +489,7 @@ drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv)
        drm_version_t *version = data;
        int len;
 
-#define DRM_COPY( name, value )                                                \
+#define DRM_COPY(name, value)                                          \
        len = strlen( value );                                          \
        if ( len > name##_len ) len = name##_len;                       \
        name##_len = strlen( value );                                   \
@@ -471,9 +498,9 @@ drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv)
                        return EFAULT;                          \
        }
 
-       version->version_major          = dev->driver.major;
-       version->version_minor          = dev->driver.minor;
-       version->version_patchlevel     = dev->driver.patchlevel;
+       version->version_major = dev->driver.major;
+       version->version_minor = dev->driver.minor;
+       version->version_patchlevel = dev->driver.patchlevel;
 
        DRM_COPY(version->name, dev->driver.name);
        DRM_COPY(version->date, dev->driver.date);
@@ -492,14 +519,14 @@ drmopen(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
        if (dev == NULL)
                return (ENXIO);
 
-       DRM_DEBUG( "open_count = %d\n", dev->open_count );
+       DRM_DEBUG("open_count = %d\n", dev->open_count);
 
        retcode = drm_open_helper(kdev, flags, fmt, p, dev);
 
-       if ( !retcode ) {
-               atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
+       if (retcode == 0) {
+               atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
                DRM_LOCK();
-               if ( !dev->open_count++ )
+               if (dev->open_count++ == 0)
                        retcode = drm_firstopen(dev);
                DRM_UNLOCK();
        }
@@ -514,7 +541,7 @@ drmclose(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
        struct drm_file *file_priv;
        int retcode = 0;
 
-       DRM_DEBUG( "open_count = %d\n", dev->open_count );
+       DRM_DEBUG("open_count = %d\n", dev->open_count);
 
        DRM_LOCK();
 
@@ -533,7 +560,7 @@ drmclose(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
         * Begin inline drm_release
         */
 
-       DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
+       DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
            DRM_CURRENTPID, (long)&dev->device, dev->open_count);
 
        if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
@@ -546,16 +573,11 @@ drmclose(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
 
                drm_lock_free(&dev->lock,
                    _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-               
-                               /* FIXME: may require heavy-handed reset of
-                                   hardware at this point, possibly
-                                   processed via a callback to the X
-                                   server. */
        } else if (dev->driver.reclaim_buffers_locked != NULL &&
            dev->lock.hw_lock != NULL) {
                /* The lock is required to reclaim buffers */
                for (;;) {
-                       if ( !dev->lock.hw_lock ) {
+                       if (dev->lock.hw_lock == NULL) {
                                /* Device has been unregistered */
                                retcode = EINTR;
                                break;
@@ -563,7 +585,7 @@ drmclose(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
                        if (drm_lock_take(&dev->lock, DRM_KERNEL_CONTEXT)) {
                                dev->lock.file_priv = file_priv;
                                dev->lock.lock_time = jiffies;
-                                atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
+                                atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
                                break;  /* Got lock */
                        }
                                /* Contention */
@@ -593,7 +615,7 @@ drmclose(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
         */
 
 done:
-       atomic_inc( &dev->counts[_DRM_STAT_CLOSES] );
+       atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
        if (--dev->open_count == 0) {
                retcode = drm_lastclose(dev);
        }
@@ -628,12 +650,12 @@ drmioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags,
                return EINVAL;
        }
 
-       atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
+       atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
        ++file_priv->ioctl_count;
 
-       DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
+       DRM_DEBUG("pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
            DRM_CURRENTPID, cmd, nr, (long)&dev->device,
-           file_priv->authenticated );
+           file_priv->authenticated);
 
        switch (cmd) {
        case FIONBIO:
@@ -670,7 +692,7 @@ drmioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags,
        func = ioctl->func;
 
        if (func == NULL) {
-               DRM_DEBUG( "no function\n" );
+               DRM_DEBUG("no function\n");
                return EINVAL;
        }
 
index bc3b2e9..558eb6c 100644 (file)
@@ -64,9 +64,9 @@ drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p,
        DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
 
        priv = drm_calloc(1, sizeof(*priv), DRM_MEM_FILES);
-       if (priv == NULL) {
+       if (priv == NULL)
                return (ENOMEM);
-       }
+
        priv->uid = DRM_UID(p);
        priv->pid = DRM_PID(p);
        priv->kdev = kdev;
index 0b40485..3cbb939 100644 (file)
@@ -98,10 +98,8 @@ drm_setunique(struct drm_device *dev, void *data, struct drm_file *file_priv)
        domain = bus >> 8;
        bus &= 0xff;
        
-       if ((domain != dev->pci_domain) ||
-           (bus != dev->pci_bus) ||
-           (slot != dev->pci_slot) ||
-           (func != dev->pci_func)) {
+       if ((domain != dev->pci_domain) || (bus != dev->pci_bus) ||
+           (slot != dev->pci_slot) || (func != dev->pci_func)) {
                drm_free(busid, u->unique_len + 1, DRM_MEM_DRIVER);
                return EINVAL;
        }
@@ -164,7 +162,7 @@ drm_getmap(struct drm_device *dev, void *data, struct drm_file *file_priv)
        }
 
        TAILQ_FOREACH(mapinlist, &dev->maplist, link) {
-               if (i==idx) {
+               if (i == idx) {
                        map->offset = mapinlist->offset;
                        map->size = mapinlist->size;
                        map->type = mapinlist->type;
@@ -195,8 +193,7 @@ drm_getclient(struct drm_device *dev, void *data, struct drm_file *file_priv)
        idx = client->idx;
        DRM_LOCK();
        TAILQ_FOREACH(pt, &dev->files, link) {
-               if (i==idx)
-               {
+               if (i==idx) {
                        client->auth = pt->authenticated;
                        client->pid = pt->pid;
                        client->uid = pt->uid;
@@ -224,8 +221,7 @@ drm_getstats(struct drm_device *dev, void *data, struct drm_file *file_priv)
 
        for (i = 0; i < dev->counters; i++) {
                if (dev->types[i] == _DRM_STAT_LOCK)
-                       stats->data[i].value
-                           = (dev->lock.hw_lock
+                       stats->data[i].value = (dev->lock.hw_lock
                            ? dev->lock.hw_lock->lock : 0);
                else 
                        stats->data[i].value = atomic_read(&dev->counts[i]);
@@ -259,12 +255,11 @@ drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv)
        sv->drm_dd_minor = dev->driver.minor;
 
        if (ver.drm_di_major != -1) {
-               if (ver.drm_di_major != DRM_IF_MAJOR ||
-                   ver.drm_di_minor < 0 || ver.drm_di_minor > DRM_IF_MINOR) {
+               if (ver.drm_di_major != DRM_IF_MAJOR || ver.drm_di_minor < 0 ||
+                   ver.drm_di_minor > DRM_IF_MINOR) {
                        return EINVAL;
                }
-               if_version = DRM_IF_VERSION(ver.drm_di_major,
-                   ver.drm_dd_minor);
+               if_version = DRM_IF_VERSION(ver.drm_di_major, ver.drm_dd_minor);
                dev->if_version = DRM_MAX(if_version, dev->if_version);
                if (ver.drm_di_minor >= 1) {
                        /*
index c02ea68..dfd0bfd 100644 (file)
@@ -36,9 +36,9 @@
 #include "drm.h"
 
 irqreturn_t    drm_irq_handler_wrap(DRM_IRQ_ARGS);
-void           vblank_disable(void *);
+void           drm_locked_task(void *, void *);
 void           drm_update_vblank_count(struct drm_device *, int);
-void           drm_locked_task(void *context, void *pending);
+void           vblank_disable(void *);
 
 int
 drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv)
@@ -53,8 +53,8 @@ drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv)
 
        irq->irq = dev->irq;
 
-       DRM_DEBUG("%d:%d:%d => IRQ %d\n",
-                 irq->busnum, irq->devnum, irq->funcnum, irq->irq);
+       DRM_DEBUG("%d:%d:%d => IRQ %d\n", irq->busnum, irq->devnum,
+           irq->funcnum, irq->irq);
 
        return 0;
 }
@@ -82,7 +82,7 @@ drm_irq_install(struct drm_device *dev)
        if (dev->irq == 0 || dev->dev_private == NULL)
                return EINVAL;
 
-       DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
+       DRM_DEBUG("irq=%d\n", dev->irq);
 
        DRM_LOCK();
        if (dev->irq_enabled) {
@@ -93,26 +93,25 @@ drm_irq_install(struct drm_device *dev)
 
        mtx_init(&dev->irq_lock, IPL_BIO);
 
-                               /* Before installing handler */
+       /* Before installing handler */
        dev->driver.irq_preinstall(dev);
        DRM_UNLOCK();
 
-                               /* Install handler */
+       /* Install handler */
        if (pci_intr_map(&dev->pa, &ih) != 0) {
                retcode = ENOENT;
                goto err;
        }
        istr = pci_intr_string(dev->pa.pa_pc, ih);
        dev->irqh = pci_intr_establish(dev->pa.pa_pc, ih, IPL_BIO,
-           drm_irq_handler_wrap, dev,
-           dev->device.dv_xname);
+           drm_irq_handler_wrap, dev, dev->device.dv_xname);
        if (!dev->irqh) {
                retcode = ENOENT;
                goto err;
        }
        DRM_DEBUG("%s: interrupting at %s\n", dev->device.dv_xname, istr);
 
-                               /* After installing handler */
+       /* After installing handler */
        DRM_LOCK();
        dev->driver.irq_postinstall(dev);
        DRM_UNLOCK();
@@ -135,7 +134,7 @@ drm_irq_uninstall(struct drm_device *dev)
 
        dev->irq_enabled = 0;
 
-       DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
+       DRM_DEBUG("irq=%d\n", dev->irq);
 
        dev->driver.irq_uninstall(dev);
 
@@ -153,7 +152,7 @@ drm_control(struct drm_device *dev, void *data, struct drm_file *file_priv)
        drm_control_t *ctl = data;
        int err;
 
-       switch ( ctl->func ) {
+       switch (ctl->func) {
        case DRM_INST_HANDLER:
                /* Handle drivers whose DRM used to require IRQ setup but the
                 * no longer does.
@@ -348,7 +347,8 @@ drm_modeset_ctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
                goto out;
        }
 
-       /* If interrupts are enabled/disabled between calls to this ioctl then
+       /*
+        * If interrupts are enabled/disabled between calls to this ioctl then
         * it can get nasty. So just grab a reference so that the interrupts
         * keep going through the modeset
         */
@@ -466,14 +466,14 @@ void
 drm_vbl_send_signals(struct drm_device *dev, int crtc)
 {
        drm_vbl_sig_t *vbl_sig;
-       unsigned int vbl_seq = atomic_read( &dev->vbl_received );
+       unsigned int vbl_seq = atomic_read(&dev->vbl_received);
        struct proc *p;
 
        vbl_sig = TAILQ_FIRST(&dev->vbl_sig_list);
        while (vbl_sig != NULL) {
                drm_vbl_sig_t *next = TAILQ_NEXT(vbl_sig, link);
 
-               if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) {
+               if ((vbl_seq - vbl_sig->sequence) <= (1<<23)) {
                        p = pfind(vbl_sig->pid);
                        if (p != NULL)
                                psignal(p, vbl_sig->signo);
index 53196e4..3a554b6 100644 (file)
@@ -57,8 +57,10 @@ drm_lock_take(struct drm_lock_data *lock_data, unsigned int context)
 
        do {
                old = *lock;
-               if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT;
-               else new = context | _DRM_LOCK_HELD;
+               if (old & _DRM_LOCK_HELD)
+                       new = old | _DRM_LOCK_CONT;
+               else
+                       new = context | _DRM_LOCK_HELD;
        } while (!atomic_cmpset_int(lock, old, new));
 
        if (_DRM_LOCKING_CONTEXT(old) == context) {
@@ -80,8 +82,7 @@ drm_lock_take(struct drm_lock_data *lock_data, unsigned int context)
 /* This takes a lock forcibly and hands it to context. Should ONLY be used
    inside *_unlock to give lock to kernel before calling *_dma_schedule. */
 int
-drm_lock_transfer(struct drm_lock_data *lock_data,
-    unsigned int context)
+drm_lock_transfer(struct drm_lock_data *lock_data, unsigned int context)
 {
        volatile unsigned int   *lock = &lock_data->hw_lock->lock;
        unsigned int             old, new;
@@ -96,8 +97,7 @@ drm_lock_transfer(struct drm_lock_data *lock_data,
 }
 
 int
-drm_lock_free(struct drm_lock_data *lock_data,
-    unsigned int context)
+drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
 {
        volatile unsigned int   *lock = &lock_data->hw_lock->lock;
        unsigned int             old, new;
index 769b853..9182811 100644 (file)
@@ -109,7 +109,7 @@ drm_ioremap(struct drm_device *dev, drm_local_map_t *map)
                }
                goto done;
        } else {
-               for (i = 0 ; i < DRM_MAX_PCI_RESOURCE; ++i) {
+               for (i = 0; i < DRM_MAX_PCI_RESOURCE; ++i) {
                        bar = vga_pci_bar_info(dev->vga_softc, i);
                        if (bar == NULL)
                                continue;
index 7e205c3..8404297 100644 (file)
  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-/**
- * \file drm_pci.h
- * \brief PCI consistent, DMA-accessible memory allocation.
- *
- * \author Eric Anholt <anholt@FreeBSD.org>
- */
-
 #include "drmP.h"
 
-/**********************************************************************/
-/** \name PCI memory */
-/*@{*/
-
-/**
- * \brief Allocate a physically contiguous DMA-accessible consistent 
+/*
+ * Allocate a physically contiguous DMA-accessible consistent 
  * memory block.
  */
 drm_dma_handle_t *
@@ -66,7 +55,7 @@ drm_pci_alloc(struct drm_device *dev, size_t size, size_t align,
                    size, align, ret);
                goto destroy;
        }
-       if(nsegs != 1) {
+       if (nsegs != 1) {
                DRM_ERROR("bus_dmamem_alloc(%zd) returned %d segments\n",
                    size, nsegs);
                goto free;
@@ -101,8 +90,8 @@ dmahfree:
 
 }
 
-/**
- * \brief Free a DMA-accessible consistent memory block.
+/*
+ * Free a DMA-accessible consistent memory block.
  */
 void
 drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah)
@@ -117,5 +106,3 @@ drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah)
 
        drm_free(dmah, sizeof(*dmah), DRM_MEM_DMA);
 }
-
-/*@}*/
index d0a2c02..5dcb7dc 100644 (file)
@@ -27,7 +27,7 @@
  *
  */
 
-/** @file drm_scatter.c
+/*
  * Allocation of memory for scatter-gather mappings by the graphics chip.
  *
  * The memory allocated here is then made into an aperture in the card
@@ -36,7 +36,7 @@
 #include "drmP.h"
 
 struct drm_sg_dmamem   *drm_sg_dmamem_alloc(struct drm_device *, size_t);
-void   drm_sg_dmamem_free(struct drm_sg_dmamem *);
+void                    drm_sg_dmamem_free(struct drm_sg_dmamem *);
 
 void
 drm_sg_cleanup(drm_sg_mem_t *entry)
@@ -57,21 +57,21 @@ drm_sg_alloc(struct drm_device * dev, drm_scatter_gather_t * request)
        unsigned long pages;
        int i;
 
-       if ( dev->sg )
+       if (dev->sg != NULL)
                return EINVAL;
 
        entry = drm_calloc(1, sizeof(*entry), DRM_MEM_SGLISTS);
-        if ( !entry )
+        if (entry == NULL)
                 return ENOMEM;
 
        pages = round_page(request->size) / PAGE_SIZE;
-       DRM_DEBUG( "sg size=%ld pages=%ld\n", request->size, pages );
+       DRM_DEBUG("sg size=%ld pages=%ld\n", request->size, pages);
 
        entry->pages = pages;
 
        entry->busaddr = drm_calloc(pages, sizeof(*entry->busaddr),
            DRM_MEM_SGLISTS);
-       if ( !entry->busaddr ) {
+       if (entry->busaddr == NULL) {
                drm_sg_cleanup(entry);
                return ENOMEM;
        }
@@ -86,7 +86,7 @@ drm_sg_alloc(struct drm_device * dev, drm_scatter_gather_t * request)
        for (i = 0; i < pages; i++) 
                entry->busaddr[i] = entry->mem->sg_map->dm_segs[i].ds_addr;
 
-       DRM_DEBUG( "sg alloc handle  = %08lx\n", entry->handle );
+       DRM_DEBUG("sg alloc handle  = %08lx\n", entry->handle);
 
        entry->virtual = (void *)entry->handle;
        request->handle = entry->handle;
@@ -110,7 +110,7 @@ drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
        drm_scatter_gather_t *request = data;
        int ret;
 
-       DRM_DEBUG( "%s\n", __FUNCTION__ );
+       DRM_DEBUG("\n");
 
        ret = drm_sg_alloc(dev, request);
        return ret;
@@ -127,10 +127,10 @@ drm_sg_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
        dev->sg = NULL;
        DRM_UNLOCK();
 
-       if ( !entry || entry->handle != request->handle )
+       if (entry == NULL || entry->handle != request->handle)
                return EINVAL;
 
-       DRM_DEBUG( "sg free virtual  = 0x%lx\n", entry->handle );
+       DRM_DEBUG("sg free virtual  = 0x%lx\n", entry->handle);
 
        drm_sg_cleanup(entry);
 
@@ -165,10 +165,8 @@ drm_sg_dmamem_alloc(struct drm_device *dev, size_t pages)
                goto segsfree;
 
        if ((ret = bus_dmamem_alloc(dev->pa.pa_dmat, size, PAGE_SIZE, 0,
-           dsd->sg_segs, pages, &dsd->sg_nsegs, BUS_DMA_NOWAIT)) != 0) {
-               printf("alloc failed, value= %d\n",ret);
+           dsd->sg_segs, pages, &dsd->sg_nsegs, BUS_DMA_NOWAIT)) != 0)
                goto destroy;
-       }
 
        if (bus_dmamem_map(dev->pa.pa_dmat, dsd->sg_segs, dsd->sg_nsegs, size, 
            &dsd->sg_kva, BUS_DMA_NOWAIT) != 0)