drm: add new drm_wait_on function to replace macro

main
Dave Airlie 2007-04-28 15:05:20 +10:00
parent e9b3acd257
commit 6e860d08d0
2 changed files with 31 additions and 1 deletions

View File

@ -1129,7 +1129,9 @@ extern struct drm_sysfs_class *drm_class;
extern struct proc_dir_entry *drm_proc_root;
extern drm_local_map_t *drm_getsarea(struct drm_device *dev);
extern int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue,
int timeout, int (*fn)(drm_device_t *dev, void *priv),
void *priv);
/* Proc support (drm_proc.h) */
extern int drm_proc_init(drm_device_t * dev,
int minor,

View File

@ -623,6 +623,34 @@ err_i1:
}
EXPORT_SYMBOL(drm_ioctl);
int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, int timeout,
int (*fn)(drm_device_t *dev, void *priv), void *priv)
{
DECLARE_WAITQUEUE(entry, current);
unsigned long end = jiffies + (timeout);
int ret = 0;
add_wait_queue(queue, &entry);
for (;;) {
__set_current_state(TASK_INTERRUPTIBLE);
if ((*fn)(dev, priv))
break;
if (time_after_eq(jiffies, end)) {
ret = -EBUSY;
break;
}
schedule_timeout((HZ/100 > 1) ? HZ/100 : 1);
if (signal_pending(current)) {
ret = -EINTR;
break;
}
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(queue, &entry);
return ret;
}
EXPORT_SYMBOL(drm_wait_on);
drm_local_map_t *drm_getsarea(struct drm_device *dev)
{
drm_map_list_t *entry;