This is just a small change to the generic read() method in drm_fops.h to use wait_event_interruptible() rather than the hand-hacked waiting code that was in there. This is the method recommended by the second edition of Linux Device Drivers . . .
On a different note, is there any way that this generic code could be factored out in a less opaque way? The way things stand, the debugging option prints out a number of function names that don't exist until the preprocessor has done it's thing - this makes it impossible to grep for them, and makes the code that much harder to get into. I was thinking something like the various structs of methods the VFS uses . . . There are probably gotchas in that, but the current code really is very hard to get into. Simon Fowler Index: programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_fops.h =================================================================== RCS file: /cvsroot/dri/xc/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_fops.h,v retrieving revision 1.7 diff -u -r1.7 drm_fops.h --- programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_fops.h 27 Jan 2002 20:05:42 -0000 1.7 +++ programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_fops.h 21 Feb 2002 +17:52:46 -0000 @@ -125,32 +125,20 @@ int avail; int send; int cur; - DECLARE_WAITQUEUE(wait, current); DRM_DEBUG("%p, %p\n", dev->buf_rp, dev->buf_wp); - add_wait_queue(&dev->buf_readers, &wait); - set_current_state(TASK_INTERRUPTIBLE); - while (dev->buf_rp == dev->buf_wp) { - DRM_DEBUG(" sleeping\n"); - if (filp->f_flags & O_NONBLOCK) { - remove_wait_queue(&dev->buf_readers, &wait); - set_current_state(TASK_RUNNING); + if (dev->buf_rp == dev->buf_wp) { + if (filp->f_flags & O_NONBLOCK) return -EAGAIN; - } - schedule(); /* wait for dev->buf_readers */ - if (signal_pending(current)) { + DRM_DEBUG(" sleeping\n"); + if(wait_event_interruptible(dev->buf_readers, (dev->buf_rp != +dev->buf_wp))) { DRM_DEBUG(" interrupted\n"); - remove_wait_queue(&dev->buf_readers, &wait); - set_current_state(TASK_RUNNING); return -ERESTARTSYS; } DRM_DEBUG(" awake\n"); - set_current_state(TASK_INTERRUPTIBLE); } - remove_wait_queue(&dev->buf_readers, &wait); - set_current_state(TASK_RUNNING); - + left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ; avail = DRM_BSZ - left; send = DRM_MIN(avail, count); -- PGP public key Id 0x144A991C, or ftp://bg77.anu.edu.au/pub/himi/himi.asc (crappy) Homepage: http://bg77.anu.edu.au doe #237 (see http://www.lemuria.org/DeCSS) My DeCSS mirror: ftp://bg77.anu.edu.au/pub/mirrors/css/
msg03020/pgp00000.pgp
Description: PGP signature