summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeif Delgass <ldelgass@users.sourceforge.net>2003-04-08 01:30:43 +0000
committerLeif Delgass <ldelgass@users.sourceforge.net>2003-04-08 01:30:43 +0000
commit10444e06d4f4edaf8e8cd9370f450ce7c047efac (patch)
tree294d347bd34529e341a363bc093287b5b236c601
parent3f7769921bd414f489d4487a5760a8d814efd51d (diff)
Use list_entry() to get container struct from struct list_head pointers.
Build fix for RedHat 9 kernel (5 args to remap_page_range()).
-rw-r--r--linux-core/drmP.h33
-rw-r--r--linux-core/drm_bufs.c2
-rw-r--r--linux-core/drm_context.c2
-rw-r--r--linux-core/drm_dma.c9
-rw-r--r--linux-core/drm_ioctl.c2
-rw-r--r--linux-core/drm_os_linux.h47
-rw-r--r--linux-core/drm_proc.c2
-rw-r--r--linux-core/drm_vm.c6
-rw-r--r--linux-core/i810_dma.c2
-rw-r--r--linux-core/i830_dma.c2
-rw-r--r--linux/Makefile.linux5
-rw-r--r--linux/drmP.h33
-rw-r--r--linux/drm_bufs.h2
-rw-r--r--linux/drm_context.h2
-rw-r--r--linux/drm_dma.h9
-rw-r--r--linux/drm_ioctl.h2
-rw-r--r--linux/drm_os_linux.h47
-rw-r--r--linux/drm_proc.h2
-rw-r--r--linux/drm_vm.h6
-rw-r--r--linux/gamma_dma.c4
-rw-r--r--linux/i810_dma.c2
-rw-r--r--linux/i830_dma.c2
22 files changed, 123 insertions, 100 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index a6b322855..59a445ea4 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -172,6 +172,15 @@
pos = n, n = pos->next)
#endif
+#ifndef list_for_each_entry
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ prefetch(pos->member.next); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member), \
+ prefetch(pos->member.next))
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
static inline struct page * vmalloc_to_page(void * vmalloc_addr)
{
@@ -197,7 +206,7 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#ifndef REMAP_PAGE_RANGE_5_ARGS /* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
#define DRM_RPR_ARG(vma)
#else
#define DRM_RPR_ARG(vma) vma,
@@ -249,17 +258,17 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
DRM(ioremapfree)( (map)->handle, (map)->size ); \
} while (0)
-#define DRM_FIND_MAP(_map, _o) \
-do { \
- struct list_head *_list; \
- list_for_each( _list, &dev->maplist->head ) { \
- drm_map_list_t *_entry = (drm_map_list_t *)_list; \
- if ( _entry->map && \
- _entry->map->offset == (_o) ) { \
- (_map) = _entry->map; \
- break; \
- } \
- } \
+#define DRM_FIND_MAP(_map, _o) \
+do { \
+ struct list_head *_list; \
+ list_for_each( _list, &dev->maplist->head ) { \
+ drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \
+ if ( _entry->map && \
+ _entry->map->offset == (_o) ) { \
+ (_map) = _entry->map; \
+ break; \
+ } \
+ } \
} while(0)
#define DRM_DROP_MAP(_map)
diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c
index b4e73699c..b27987f1a 100644
--- a/linux-core/drm_bufs.c
+++ b/linux-core/drm_bufs.c
@@ -211,7 +211,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
down(&dev->struct_sem);
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 &&
r_list->map->handle == request.handle &&
diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c
index 39267b14b..88b485ff2 100644
--- a/linux-core/drm_context.c
+++ b/linux-core/drm_context.c
@@ -195,7 +195,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
down(&dev->struct_sem);
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 &&
r_list->map->handle == request.handle)
goto found;
diff --git a/linux-core/drm_dma.c b/linux-core/drm_dma.c
index 4ea6b07d9..71e25b3d8 100644
--- a/linux-core/drm_dma.c
+++ b/linux-core/drm_dma.c
@@ -655,7 +655,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
* for the same vblank sequence number; nothing to be done in
* 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
&& vbl_sig->info.si_signo == vblwait.request.signal
&& vbl_sig->task == current)
@@ -706,19 +706,20 @@ done:
void DRM(vbl_send_signals)( drm_device_t *dev )
{
- struct list_head *tmp;
+ struct list_head *list, *tmp;
drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received );
unsigned long 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) ) {
vbl_sig->info.si_code = vbl_seq;
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) );
diff --git a/linux-core/drm_ioctl.c b/linux-core/drm_ioctl.c
index d753cce0d..9b1069a15 100644
--- a/linux-core/drm_ioctl.c
+++ b/linux-core/drm_ioctl.c
@@ -205,7 +205,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp,
i = 0;
list_for_each(list, &dev->maplist->head) {
if(i == idx) {
- r_list = (drm_map_list_t *)list;
+ r_list = list_entry(list, drm_map_list_t, head);
break;
}
i++;
diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h
index b57efd348..b760c1694 100644
--- a/linux-core/drm_os_linux.h
+++ b/linux-core/drm_os_linux.h
@@ -47,9 +47,8 @@
#define DRM_GETSAREA() \
do { \
- struct list_head *list; \
- list_for_each( list, &dev->maplist->head ) { \
- drm_map_list_t *entry = (drm_map_list_t *)list; \
+ drm_map_list_t *entry; \
+ list_for_each_entry( entry, &dev->maplist->head, head ) { \
if ( entry->map && \
entry->map->type == _DRM_SHM && \
(entry->map->flags & _DRM_CONTAINS_LOCK) ) { \
@@ -61,28 +60,28 @@ do { \
#define DRM_HZ HZ
-#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-do { \
- DECLARE_WAITQUEUE(entry, current); \
- unsigned long end = jiffies + (timeout); \
- add_wait_queue(&(queue), &entry); \
- \
- for (;;) { \
- current->state = TASK_INTERRUPTIBLE; \
- if (condition) \
- break; \
- if((signed)(end - jiffies) <= 0) { \
- ret = -EBUSY; \
- break; \
- } \
+#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
+do { \
+ DECLARE_WAITQUEUE(entry, current); \
+ unsigned long end = jiffies + (timeout); \
+ add_wait_queue(&(queue), &entry); \
+ \
+ for (;;) { \
+ current->state = TASK_INTERRUPTIBLE; \
+ if (condition) \
+ break; \
+ if((signed)(end - jiffies) <= 0) { \
+ ret = -EBUSY; \
+ break; \
+ } \
schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
- if (signal_pending(current)) { \
- ret = -EINTR; \
- break; \
- } \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&(queue), &entry); \
+ if (signal_pending(current)) { \
+ ret = -EINTR; \
+ break; \
+ } \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&(queue), &entry); \
} while (0)
diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c
index 8524d2048..5af8ddeac 100644
--- a/linux-core/drm_proc.c
+++ b/linux-core/drm_proc.c
@@ -187,7 +187,7 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
"address mtrr\n\n");
i = 0;
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;
if(!map) continue;
if (map->type < 0 || map->type > 4) type = "??";
diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c
index 9101e1365..76a10cf54 100644
--- a/linux-core/drm_vm.c
+++ b/linux-core/drm_vm.c
@@ -74,7 +74,7 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
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;
if (!map) continue;
if (map->offset == VM_OFFSET(vma)) break;
@@ -190,7 +190,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
found_maps = 0;
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++;
}
@@ -393,7 +393,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
list_for_each(list, &dev->maplist->head) {
unsigned long off;
- r_list = (drm_map_list_t *)list;
+ r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map;
if (!map) continue;
off = DRIVER_GET_MAP_OFS();
diff --git a/linux-core/i810_dma.c b/linux-core/i810_dma.c
index de9345e3b..b0a1b6aac 100644
--- a/linux-core/i810_dma.c
+++ b/linux-core/i810_dma.c
@@ -347,7 +347,7 @@ static int i810_dma_initialize(drm_device_t *dev,
memset(dev_priv, 0, sizeof(drm_i810_private_t));
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 &&
r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) {
diff --git a/linux-core/i830_dma.c b/linux-core/i830_dma.c
index 47f10d56f..1018fdcb9 100644
--- a/linux-core/i830_dma.c
+++ b/linux-core/i830_dma.c
@@ -370,7 +370,7 @@ static int i830_dma_initialize(drm_device_t *dev,
memset(dev_priv, 0, sizeof(drm_i830_private_t));
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 &&
r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) {
diff --git a/linux/Makefile.linux b/linux/Makefile.linux
index 065d6f62b..63bec30d2 100644
--- a/linux/Makefile.linux
+++ b/linux/Makefile.linux
@@ -144,6 +144,8 @@ AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
MACHINE := $(shell echo `uname -m`)
# Red Hat's kernels have 4 args to do_munmap()
DOMUNMAP := $(shell grep do_munmap $(TREE)/linux/mm.h | grep -c acct)
+# Red Hat 9 kernel has 5 args to remap_page_range()
+RPR := $(shell grep remap_page_range $(TREE)/linux/mm.h | grep -c vma)
ifeq ($(AGP),0)
AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'AGP_MODULE = ' | cut -d' ' -f3)
@@ -152,6 +154,9 @@ endif
ifeq ($(DOMUNMAP),1)
MODCFLAGS += -DDO_MUNMAP_4_ARGS
endif
+ifeq ($(RPR),1)
+MODCFLAGS += -DREMAP_PAGE_RANGE_5_ARGS
+endif
ifeq ($(AGP),1)
MODCFLAGS += -DCONFIG_AGP -DCONFIG_AGP_MODULE
DRMTEMPLATES += drm_agpsupport.h
diff --git a/linux/drmP.h b/linux/drmP.h
index a6b322855..59a445ea4 100644
--- a/linux/drmP.h
+++ b/linux/drmP.h
@@ -172,6 +172,15 @@
pos = n, n = pos->next)
#endif
+#ifndef list_for_each_entry
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ prefetch(pos->member.next); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member), \
+ prefetch(pos->member.next))
+#endif
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
static inline struct page * vmalloc_to_page(void * vmalloc_addr)
{
@@ -197,7 +206,7 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
}
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+#ifndef REMAP_PAGE_RANGE_5_ARGS /* #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) */
#define DRM_RPR_ARG(vma)
#else
#define DRM_RPR_ARG(vma) vma,
@@ -249,17 +258,17 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
DRM(ioremapfree)( (map)->handle, (map)->size ); \
} while (0)
-#define DRM_FIND_MAP(_map, _o) \
-do { \
- struct list_head *_list; \
- list_for_each( _list, &dev->maplist->head ) { \
- drm_map_list_t *_entry = (drm_map_list_t *)_list; \
- if ( _entry->map && \
- _entry->map->offset == (_o) ) { \
- (_map) = _entry->map; \
- break; \
- } \
- } \
+#define DRM_FIND_MAP(_map, _o) \
+do { \
+ struct list_head *_list; \
+ list_for_each( _list, &dev->maplist->head ) { \
+ drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \
+ if ( _entry->map && \
+ _entry->map->offset == (_o) ) { \
+ (_map) = _entry->map; \
+ break; \
+ } \
+ } \
} while(0)
#define DRM_DROP_MAP(_map)
diff --git a/linux/drm_bufs.h b/linux/drm_bufs.h
index b4e73699c..b27987f1a 100644
--- a/linux/drm_bufs.h
+++ b/linux/drm_bufs.h
@@ -211,7 +211,7 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
down(&dev->struct_sem);
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 &&
r_list->map->handle == request.handle &&
diff --git a/linux/drm_context.h b/linux/drm_context.h
index 39267b14b..88b485ff2 100644
--- a/linux/drm_context.h
+++ b/linux/drm_context.h
@@ -195,7 +195,7 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
down(&dev->struct_sem);
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 &&
r_list->map->handle == request.handle)
goto found;
diff --git a/linux/drm_dma.h b/linux/drm_dma.h
index 4ea6b07d9..71e25b3d8 100644
--- a/linux/drm_dma.h
+++ b/linux/drm_dma.h
@@ -655,7 +655,7 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
* for the same vblank sequence number; nothing to be done in
* 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
&& vbl_sig->info.si_signo == vblwait.request.signal
&& vbl_sig->task == current)
@@ -706,19 +706,20 @@ done:
void DRM(vbl_send_signals)( drm_device_t *dev )
{
- struct list_head *tmp;
+ struct list_head *list, *tmp;
drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received );
unsigned long 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) ) {
vbl_sig->info.si_code = vbl_seq;
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) );
diff --git a/linux/drm_ioctl.h b/linux/drm_ioctl.h
index d753cce0d..9b1069a15 100644
--- a/linux/drm_ioctl.h
+++ b/linux/drm_ioctl.h
@@ -205,7 +205,7 @@ int DRM(getmap)( struct inode *inode, struct file *filp,
i = 0;
list_for_each(list, &dev->maplist->head) {
if(i == idx) {
- r_list = (drm_map_list_t *)list;
+ r_list = list_entry(list, drm_map_list_t, head);
break;
}
i++;
diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h
index b57efd348..b760c1694 100644
--- a/linux/drm_os_linux.h
+++ b/linux/drm_os_linux.h
@@ -47,9 +47,8 @@
#define DRM_GETSAREA() \
do { \
- struct list_head *list; \
- list_for_each( list, &dev->maplist->head ) { \
- drm_map_list_t *entry = (drm_map_list_t *)list; \
+ drm_map_list_t *entry; \
+ list_for_each_entry( entry, &dev->maplist->head, head ) { \
if ( entry->map && \
entry->map->type == _DRM_SHM && \
(entry->map->flags & _DRM_CONTAINS_LOCK) ) { \
@@ -61,28 +60,28 @@ do { \
#define DRM_HZ HZ
-#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-do { \
- DECLARE_WAITQUEUE(entry, current); \
- unsigned long end = jiffies + (timeout); \
- add_wait_queue(&(queue), &entry); \
- \
- for (;;) { \
- current->state = TASK_INTERRUPTIBLE; \
- if (condition) \
- break; \
- if((signed)(end - jiffies) <= 0) { \
- ret = -EBUSY; \
- break; \
- } \
+#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
+do { \
+ DECLARE_WAITQUEUE(entry, current); \
+ unsigned long end = jiffies + (timeout); \
+ add_wait_queue(&(queue), &entry); \
+ \
+ for (;;) { \
+ current->state = TASK_INTERRUPTIBLE; \
+ if (condition) \
+ break; \
+ if((signed)(end - jiffies) <= 0) { \
+ ret = -EBUSY; \
+ break; \
+ } \
schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
- if (signal_pending(current)) { \
- ret = -EINTR; \
- break; \
- } \
- } \
- current->state = TASK_RUNNING; \
- remove_wait_queue(&(queue), &entry); \
+ if (signal_pending(current)) { \
+ ret = -EINTR; \
+ break; \
+ } \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&(queue), &entry); \
} while (0)
diff --git a/linux/drm_proc.h b/linux/drm_proc.h
index 8524d2048..5af8ddeac 100644
--- a/linux/drm_proc.h
+++ b/linux/drm_proc.h
@@ -187,7 +187,7 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
"address mtrr\n\n");
i = 0;
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;
if(!map) continue;
if (map->type < 0 || map->type > 4) type = "??";
diff --git a/linux/drm_vm.h b/linux/drm_vm.h
index 9101e1365..76a10cf54 100644
--- a/linux/drm_vm.h
+++ b/linux/drm_vm.h
@@ -74,7 +74,7 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
if(!dev->agp || !dev->agp->cant_use_aperture) goto vm_nopage_error;
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;
if (!map) continue;
if (map->offset == VM_OFFSET(vma)) break;
@@ -190,7 +190,7 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
found_maps = 0;
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++;
}
@@ -393,7 +393,7 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma)
list_for_each(list, &dev->maplist->head) {
unsigned long off;
- r_list = (drm_map_list_t *)list;
+ r_list = list_entry(list, drm_map_list_t, head);
map = r_list->map;
if (!map) continue;
off = DRIVER_GET_MAP_OFS();
diff --git a/linux/gamma_dma.c b/linux/gamma_dma.c
index a3c21d110..5b4d84bcb 100644
--- a/linux/gamma_dma.c
+++ b/linux/gamma_dma.c
@@ -607,7 +607,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) );
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 &&
r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) {
@@ -811,7 +811,7 @@ int gamma_setsareactx(struct inode *inode, struct file *filp,
down(&dev->struct_sem);
r_list = 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);
if(r_list->map &&
r_list->map->handle == request.handle) break;
}
diff --git a/linux/i810_dma.c b/linux/i810_dma.c
index de9345e3b..b0a1b6aac 100644
--- a/linux/i810_dma.c
+++ b/linux/i810_dma.c
@@ -347,7 +347,7 @@ static int i810_dma_initialize(drm_device_t *dev,
memset(dev_priv, 0, sizeof(drm_i810_private_t));
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 &&
r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) {
diff --git a/linux/i830_dma.c b/linux/i830_dma.c
index 47f10d56f..1018fdcb9 100644
--- a/linux/i830_dma.c
+++ b/linux/i830_dma.c
@@ -370,7 +370,7 @@ static int i830_dma_initialize(drm_device_t *dev,
memset(dev_priv, 0, sizeof(drm_i830_private_t));
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 &&
r_list->map->type == _DRM_SHM &&
r_list->map->flags & _DRM_CONTAINS_LOCK ) {