Use list_entry() to get container struct from struct list_head pointers.

Build fix for RedHat 9 kernel (5 args to remap_page_range()).
main
Leif Delgass 2003-04-08 01:30:43 +00:00
parent 3f7769921b
commit 10444e06d4
22 changed files with 123 additions and 100 deletions

View File

@ -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,
@ -253,7 +262,7 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
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_entry( _list, drm_map_list_t, head ); \
if ( _entry->map && \
_entry->map->offset == (_o) ) { \
(_map) = _entry->map; \

View File

@ -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 &&

View File

@ -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;

View File

@ -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) );

View File

@ -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++;

View File

@ -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) ) { \

View File

@ -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 = "??";

View File

@ -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();

View File

@ -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 ) {

View File

@ -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 ) {

View File

@ -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

View File

@ -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,
@ -253,7 +262,7 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
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_entry( _list, drm_map_list_t, head ); \
if ( _entry->map && \
_entry->map->offset == (_o) ) { \
(_map) = _entry->map; \

View File

@ -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 &&

View File

@ -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;

View File

@ -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) );

View File

@ -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++;

View File

@ -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) ) { \

View File

@ -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 = "??";

View File

@ -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();

View File

@ -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;
}

View File

@ -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 ) {

View File

@ -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 ) {