static int scullc_defer_op(int write, struct kiocb *iocb, char __user *buf, size_t count, loff_t pos) { struct delayed_work *stuff; int result; /* Copy now while we can access the buffer */ if (write) result = scullc_write(iocb->ki_filp, buf, count, &pos); else result = scullc_read(iocb->ki_filp, buf, count, &pos); /* If this is a synchronous IOCB, we return our status now. */ if (is_sync_kiocb(iocb)) return result; /* Otherwise defer the completion for a few milliseconds. */ stuff = kmalloc (sizeof (*stuff), GFP_KERNEL); if (stuff == NULL) return result; /* No memory, just complete now */ //stuff->iocb = iocb; //stuff->result = result; INIT_DELAYED_WORK(stuff, scullc_do_deferred_op); schedule_delayed_work(stuff, HZ/100); return -EIOCBQUEUED; }
static int scullc_defer_op(int write, struct kiocb *iocb, const struct iovec * iov, unsigned long count, loff_t pos) { struct async_work *stuff; int result = 0; /* Copy now while we can access the buffer */ if (write) { result = scullc_write(iocb->ki_filp, iov->iov_base, iov->iov_len, &pos); } else { result = scullc_read(iocb->ki_filp, iov->iov_base, iov->iov_len, &pos); } /* If this is a synchronous IOCB, we return our status now. */ if (is_sync_kiocb(iocb)) return result; /* Otherwise defer the completion for a few milliseconds. */ stuff = kmalloc (sizeof (*stuff), GFP_KERNEL); if (stuff == NULL) return result; /* No memory, just complete now */ stuff->iocb = iocb; stuff->result = result; INIT_DELAYED_WORK(&stuff->dwork, scullc_do_deferred_op); schedule_delayed_work(&stuff->dwork, HZ/100); return -EIOCBQUEUED; }