On Dinsdag 15 Februar 2005 02:04, Nishanth Aravamudan wrote: > Here's at least one example: > > drivers/ieee1394/video1394.c:__video1394_ioctl() > AFAICS, that one should work just fine using after converting
while (d->buffer_status[v.buffer]!= VIDEO1394_BUFFER_READY) { spin_unlock_irqrestore(&d->lock, flags); interruptible_sleep_on(&d->waitq); spin_lock_irqsave(&d->lock, flags); if (signal_pending(current)) { spin_unlock_irqrestore(&d->lock,flags); return -EINTR; } } to static inline unsigned video1394_buffer_state(struct dma_iso_ctx *d, unsigned int buffer) { unsigned long flags; unsigned int ret; spin_lock_irqsave(&d->lock, flags); ret = d->buffer_status[buffer]; spin_unlock_irqrestore(&d->lock, flags); return ret; } ... spin_unlock_irqrestore(&d->lock, flags); if (wait_event_interruptible(d->waitq, video1394_buffer_state(d, v.buffer) == VIDEO1394_BUFFER_READY)) return -EINTR; spin_lock_irqsave(&d->lock, flags); The trick here is that it is known in advance that the state does not actually have to be protected by the lock after reading it, because the state can not change from READY to FREE in any other place in the code. One exception might be two processes calling the ioctl at the same time, but I think that is racy will any of these variations. Arnd <><
pgptxdQzg1nIX.pgp
Description: signature