summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
Diffstat (limited to 'linux-core')
-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
10 files changed, 58 insertions, 49 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index a6b32285..59a445ea 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 b4e73699..b27987f1 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 39267b14..88b485ff 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 4ea6b07d..71e25b3d 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 d753cce0..9b1069a1 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 b57efd34..b760c169 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 8524d204..5af8ddea 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 9101e136..76a10cf5 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 de9345e3..b0a1b6aa 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 47f10d56..1018fdcb 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 ) {