Commit 898df34c authored by Linus Torvalds's avatar Linus Torvalds

Merge from DRI CVS: Use the list_entry() macro instead of depending

on the list-head being at the top of the DRI data structures and
using hard casts.
parent 2f5c576e
...@@ -242,17 +242,17 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr) ...@@ -242,17 +242,17 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
DRM(ioremapfree)( (map)->handle, (map)->size ); \ DRM(ioremapfree)( (map)->handle, (map)->size ); \
} while (0) } while (0)
#define DRM_FIND_MAP(_map, _o) \ #define DRM_FIND_MAP(_map, _o) \
do { \ do { \
struct list_head *_list; \ struct list_head *_list; \
list_for_each( _list, &dev->maplist->head ) { \ list_for_each( _list, &dev->maplist->head ) { \
drm_map_list_t *_entry = (drm_map_list_t *)_list; \ drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \
if ( _entry->map && \ if ( _entry->map && \
_entry->map->offset == (_o) ) { \ _entry->map->offset == (_o) ) { \
(_map) = _entry->map; \ (_map) = _entry->map; \
break; \ break; \
} \ } \
} \ } \
} while(0) } while(0)
#define DRM_DROP_MAP(_map) #define DRM_DROP_MAP(_map)
......
...@@ -210,7 +210,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp, ...@@ -210,7 +210,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
down(&dev->struct_sem); down(&dev->struct_sem);
list = &dev->maplist->head; list = &dev->maplist->head;
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *) list; r_list = list_entry(list, drm_map_list_t, head);
if(r_list->map && if(r_list->map &&
r_list->map->handle == request.handle && r_list->map->handle == request.handle &&
......
...@@ -194,7 +194,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp, ...@@ -194,7 +194,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
down(&dev->struct_sem); down(&dev->struct_sem);
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list; r_list = list_entry(list, drm_map_list_t, head);
if(r_list->map && if(r_list->map &&
r_list->map->handle == request.handle) r_list->map->handle == request.handle)
goto found; goto found;
......
...@@ -444,7 +444,7 @@ static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d, ...@@ -444,7 +444,7 @@ static int DRM(dma_get_buffers_of_order)(struct file *filp, drm_dma_t *d,
d->flags & _DRM_DMA_WAIT); d->flags & _DRM_DMA_WAIT);
if (!buf) break; if (!buf) break;
if (buf->pending || buf->waiting) { if (buf->pending || buf->waiting) {
DRM_ERROR("Free buffer %d in use by %x (w%d, p%d)\n", DRM_ERROR("Free buffer %d in use: filp %p (w%d, p%d)\n",
buf->idx, buf->idx,
buf->filp, buf->filp,
buf->waiting, buf->waiting,
...@@ -651,7 +651,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -651,7 +651,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
* for the same vblank sequence number; nothing to be done in * for the same vblank sequence number; nothing to be done in
* that case * that case
*/ */
list_for_each( ( (struct list_head *) vbl_sig ), &dev->vbl_sigs.head ) { list_for_each_entry( vbl_sig, &dev->vbl_sigs.head, head ) {
if (vbl_sig->sequence == vblwait.request.sequence if (vbl_sig->sequence == vblwait.request.sequence
&& vbl_sig->info.si_signo == vblwait.request.signal && vbl_sig->info.si_signo == vblwait.request.signal
&& vbl_sig->task == current) && vbl_sig->task == current)
...@@ -702,19 +702,20 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS ) ...@@ -702,19 +702,20 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
void DRM(vbl_send_signals)( drm_device_t *dev ) void DRM(vbl_send_signals)( drm_device_t *dev )
{ {
struct list_head *tmp; struct list_head *list, *tmp;
drm_vbl_sig_t *vbl_sig; drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received ); unsigned int vbl_seq = atomic_read( &dev->vbl_received );
unsigned long flags; unsigned long flags;
spin_lock_irqsave( &dev->vbl_lock, flags ); spin_lock_irqsave( &dev->vbl_lock, flags );
list_for_each_safe( ( (struct list_head *) vbl_sig ), tmp, &dev->vbl_sigs.head ) { list_for_each_safe( list, tmp, &dev->vbl_sigs.head ) {
vbl_sig = list_entry( list, drm_vbl_sig_t, head );
if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) { if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) {
vbl_sig->info.si_code = vbl_seq; vbl_sig->info.si_code = vbl_seq;
send_sig_info( vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task ); send_sig_info( vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task );
list_del( (struct list_head *) vbl_sig ); list_del( list );
DRM_FREE( vbl_sig, sizeof(*vbl_sig) ); DRM_FREE( vbl_sig, sizeof(*vbl_sig) );
......
...@@ -204,7 +204,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp, ...@@ -204,7 +204,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp,
i = 0; i = 0;
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
if(i == idx) { if(i == idx) {
r_list = (drm_map_list_t *)list; r_list = list_entry(list, drm_map_list_t, head);
break; break;
} }
i++; i++;
......
...@@ -46,9 +46,8 @@ ...@@ -46,9 +46,8 @@
#define DRM_GETSAREA() \ #define DRM_GETSAREA() \
do { \ do { \
struct list_head *list; \ drm_map_list_t *entry; \
list_for_each( list, &dev->maplist->head ) { \ list_for_each_entry( entry, &dev->maplist->head, head ) { \
drm_map_list_t *entry = (drm_map_list_t *)list; \
if ( entry->map && \ if ( entry->map && \
entry->map->type == _DRM_SHM && \ entry->map->type == _DRM_SHM && \
(entry->map->flags & _DRM_CONTAINS_LOCK) ) { \ (entry->map->flags & _DRM_CONTAINS_LOCK) ) { \
...@@ -60,28 +59,28 @@ do { \ ...@@ -60,28 +59,28 @@ do { \
#define DRM_HZ HZ #define DRM_HZ HZ
#define DRM_WAIT_ON( ret, queue, timeout, condition ) \ #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
do { \ do { \
DECLARE_WAITQUEUE(entry, current); \ DECLARE_WAITQUEUE(entry, current); \
unsigned long end = jiffies + (timeout); \ unsigned long end = jiffies + (timeout); \
add_wait_queue(&(queue), &entry); \ add_wait_queue(&(queue), &entry); \
\ \
for (;;) { \ for (;;) { \
current->state = TASK_INTERRUPTIBLE; \ current->state = TASK_INTERRUPTIBLE; \
if (condition) \ if (condition) \
break; \ break; \
if((signed)(end - jiffies) <= 0) { \ if (time_after_eq(jiffies, end)) { \
ret = -EBUSY; \ ret = -EBUSY; \
break; \ break; \
} \ } \
schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \ schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
if (signal_pending(current)) { \ if (signal_pending(current)) { \
ret = -EINTR; \ ret = -EINTR; \
break; \ break; \
} \ } \
} \ } \
current->state = TASK_RUNNING; \ current->state = TASK_RUNNING; \
remove_wait_queue(&(queue), &entry); \ remove_wait_queue(&(queue), &entry); \
} while (0) } while (0)
......
...@@ -168,9 +168,9 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request, ...@@ -168,9 +168,9 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
struct list_head *list; struct list_head *list;
/* Hardcoded from _DRM_FRAME_BUFFER, /* Hardcoded from _DRM_FRAME_BUFFER,
_DRM_REGISTERS, _DRM_SHM, and _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
_DRM_AGP. */ _DRM_SCATTER_GATHER. */
const char *types[] = { "FB", "REG", "SHM", "AGP" }; const char *types[] = { "FB", "REG", "SHM", "AGP", "SG" };
const char *type; const char *type;
int i; int i;
...@@ -186,10 +186,10 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request, ...@@ -186,10 +186,10 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
"address mtrr\n\n"); "address mtrr\n\n");
i = 0; i = 0;
if (dev->maplist != NULL) list_for_each(list, &dev->maplist->head) { if (dev->maplist != NULL) list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list; r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map; map = r_list->map;
if(!map) continue; if(!map) continue;
if (map->type < 0 || map->type > 3) type = "??"; if (map->type < 0 || map->type > 4) type = "??";
else type = types[map->type]; else type = types[map->type];
DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ", DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ",
i, i,
......
...@@ -73,7 +73,7 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma, ...@@ -73,7 +73,7 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error; if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list; r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map; map = r_list->map;
if (!map) continue; if (!map) continue;
if (map->offset == VM_OFFSET(vma)) break; if (map->offset == VM_OFFSET(vma)) break;
...@@ -189,7 +189,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma) ...@@ -189,7 +189,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
found_maps = 0; found_maps = 0;
list = &dev->maplist->head; list = &dev->maplist->head;
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *) list; r_list = list_entry(list, drm_map_list_t, head);
if (r_list->map == map) found_maps++; if (r_list->map == map) found_maps++;
} }
...@@ -392,7 +392,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) ...@@ -392,7 +392,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
unsigned long off; unsigned long off;
r_list = (drm_map_list_t *)list; r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map; map = r_list->map;
if (!map) continue; if (!map) continue;
off = DRIVER_GET_MAP_OFS(); off = DRIVER_GET_MAP_OFS();
......
...@@ -605,7 +605,7 @@ static int gamma_do_init_dma( drm_device_t *dev, drm_gamma_init_t *init ) ...@@ -605,7 +605,7 @@ static int gamma_do_init_dma( drm_device_t *dev, drm_gamma_init_t *init )
memset( dev_priv, 0, sizeof(drm_gamma_private_t) ); memset( dev_priv, 0, sizeof(drm_gamma_private_t) );
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
drm_map_list_t *r_list = (drm_map_list_t *)list; drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
if( r_list->map && if( r_list->map &&
r_list->map->type == _DRM_SHM && r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) { r_list->map->flags & _DRM_CONTAINS_LOCK ) {
...@@ -809,7 +809,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp, ...@@ -809,7 +809,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp,
down(&dev->struct_sem); down(&dev->struct_sem);
r_list = NULL; r_list = NULL;
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
r_list = (drm_map_list_t *)list; r_list = list_entry(list, drm_map_list_t, head);
if(r_list->map && if(r_list->map &&
r_list->map->handle == request.handle) break; r_list->map->handle == request.handle) break;
} }
......
...@@ -340,7 +340,7 @@ static int i810_dma_initialize(drm_device_t *dev, ...@@ -340,7 +340,7 @@ static int i810_dma_initialize(drm_device_t *dev,
memset(dev_priv, 0, sizeof(drm_i810_private_t)); memset(dev_priv, 0, sizeof(drm_i810_private_t));
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
drm_map_list_t *r_list = (drm_map_list_t *)list; drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
if( r_list->map && if( r_list->map &&
r_list->map->type == _DRM_SHM && r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) { r_list->map->flags & _DRM_CONTAINS_LOCK ) {
......
...@@ -363,7 +363,7 @@ static int i830_dma_initialize(drm_device_t *dev, ...@@ -363,7 +363,7 @@ static int i830_dma_initialize(drm_device_t *dev,
memset(dev_priv, 0, sizeof(drm_i830_private_t)); memset(dev_priv, 0, sizeof(drm_i830_private_t));
list_for_each(list, &dev->maplist->head) { list_for_each(list, &dev->maplist->head) {
drm_map_list_t *r_list = (drm_map_list_t *)list; drm_map_list_t *r_list = list_entry(list, drm_map_list_t, head);
if( r_list->map && if( r_list->map &&
r_list->map->type == _DRM_SHM && r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) { r_list->map->flags & _DRM_CONTAINS_LOCK ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment