summaryrefslogtreecommitdiffstats
path: root/scullv/main.c
diff options
context:
space:
mode:
authorJavier Martinez Canillas <martinez.javier@gmail.com>2010-12-07 01:55:20 +0100
committerJavier Martinez Canillas <martinez.javier@gmail.com>2010-12-07 01:55:20 +0100
commitf2fb1a5058a0f8637cc0f66b160d302773f5e557 (patch)
tree3fd21f5152408ab941dc4686848b511e9eea6ea7 /scullv/main.c
parented7e9e684b6de17db6af5bdc20bf91bf89e73d9d (diff)
downloadldd3-f2fb1a5058a0f8637cc0f66b160d302773f5e557.tar.gz
scullv: Change work_struct to delayed_work and change scullc_aio_[read | write] handlers
Diffstat (limited to 'scullv/main.c')
-rw-r--r--scullv/main.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/scullv/main.c b/scullv/main.c
index 71aa048..a05095d 100644
--- a/scullv/main.c
+++ b/scullv/main.c
@@ -399,31 +399,40 @@ loff_t scullv_llseek (struct file *filp, loff_t off, int whence)
struct async_work {
struct kiocb *iocb;
int result;
- struct work_struct work;
+ struct delayed_work work;
};
/*
* "Complete" an asynchronous operation.
*/
-static void scullv_do_deferred_op(void *p)
+static void scullv_do_deferred_op(struct work_struct *work)
{
- struct async_work *stuff = (struct async_work *) p;
+ struct async_work *stuff = container_of(work, struct async_work, work.work);
aio_complete(stuff->iocb, stuff->result, 0);
kfree(stuff);
}
-static int scullv_defer_op(int write, struct kiocb *iocb, char __user *buf,
- size_t count, loff_t pos)
+static int scullv_defer_op(int write, struct kiocb *iocb, const struct iovec *iovec,
+ unsigned long nr_segs, loff_t pos)
{
struct async_work *stuff;
- int result;
+ int result = 0;
+ size_t len = 0;
+ unsigned long seg = 0;
/* Copy now while we can access the buffer */
- if (write)
- result = scullv_write(iocb->ki_filp, buf, count, &pos);
- else
- result = scullv_read(iocb->ki_filp, buf, count, &pos);
+ for (seg = 0; seg < nr_segs; seg++) {
+ if (write)
+ len = scullv_write(iocb->ki_filp, iovec[seg].iov_base, iovec[seg].iov_len, &pos);
+ else
+ len = scullv_read(iocb->ki_filp, iovec[seg].iov_base, iovec[seg].iov_len, &pos);
+
+ if (len < 0)
+ return len;
+
+ result += len;
+ }
/* If this is a synchronous IOCB, we return our status now. */
if (is_sync_kiocb(iocb))
@@ -435,7 +444,7 @@ static int scullv_defer_op(int write, struct kiocb *iocb, char __user *buf,
return result; /* No memory, just complete now */
stuff->iocb = iocb;
stuff->result = result;
- INIT_WORK(&stuff->work, scullv_do_deferred_op, stuff);
+ INIT_DELAYED_WORK(&stuff->work, scullv_do_deferred_op);
schedule_delayed_work(&stuff->work, HZ/100);
return -EIOCBQUEUED;
}