[PATCH] struct seq_operations and struct file_operations constification
[pandora-kernel.git] / kernel / relay.c
index 1d63ecd..75a3a9a 100644 (file)
@@ -308,9 +308,10 @@ static struct rchan_callbacks default_channel_callbacks = {
  *     reason waking is deferred is that calling directly from write
  *     causes problems if you're writing from say the scheduler.
  */
-static void wakeup_readers(void *private)
+static void wakeup_readers(struct work_struct *work)
 {
-       struct rchan_buf *buf = private;
+       struct rchan_buf *buf =
+               container_of(work, struct rchan_buf, wake_readers.work);
        wake_up_interruptible(&buf->read_wait);
 }
 
@@ -328,7 +329,7 @@ static inline void __relay_reset(struct rchan_buf *buf, unsigned int init)
        if (init) {
                init_waitqueue_head(&buf->read_wait);
                kref_init(&buf->kref);
-               INIT_WORK(&buf->wake_readers, NULL, NULL);
+               INIT_DELAYED_WORK(&buf->wake_readers, NULL);
        } else {
                cancel_delayed_work(&buf->wake_readers);
                flush_scheduled_work();
@@ -549,7 +550,8 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
                        buf->padding[old_subbuf];
                smp_mb();
                if (waitqueue_active(&buf->read_wait)) {
-                       PREPARE_WORK(&buf->wake_readers, wakeup_readers, buf);
+                       PREPARE_DELAYED_WORK(&buf->wake_readers,
+                                            wakeup_readers);
                        schedule_delayed_work(&buf->wake_readers, 1);
                }
        }
@@ -887,7 +889,7 @@ static int subbuf_read_actor(size_t read_start,
 
        from = buf->start + read_start;
        ret = avail;
-       if (copy_to_user(desc->arg.data, from, avail)) {
+       if (copy_to_user(desc->arg.buf, from, avail)) {
                desc->error = -EFAULT;
                ret = 0;
        }
@@ -946,24 +948,17 @@ typedef int (*subbuf_actor_t) (size_t read_start,
  */
 static inline ssize_t relay_file_read_subbufs(struct file *filp,
                                              loff_t *ppos,
-                                             size_t count,
                                              subbuf_actor_t subbuf_actor,
                                              read_actor_t actor,
-                                             void *target)
+                                             read_descriptor_t *desc)
 {
        struct rchan_buf *buf = filp->private_data;
        size_t read_start, avail;
-       read_descriptor_t desc;
        int ret;
 
-       if (!count)
+       if (!desc->count)
                return 0;
 
-       desc.written = 0;
-       desc.count = count;
-       desc.arg.data = target;
-       desc.error = 0;
-
        mutex_lock(&filp->f_dentry->d_inode->i_mutex);
        do {
                if (!relay_file_read_avail(buf, *ppos))
@@ -974,19 +969,19 @@ static inline ssize_t relay_file_read_subbufs(struct file *filp,
                if (!avail)
                        break;
 
-               avail = min(desc.count, avail);
-               ret = subbuf_actor(read_start, buf, avail, &desc, actor);
-               if (desc.error < 0)
+               avail = min(desc->count, avail);
+               ret = subbuf_actor(read_start, buf, avail, desc, actor);
+               if (desc->error < 0)
                        break;
 
                if (ret) {
                        relay_file_read_consume(buf, read_start, ret);
                        *ppos = relay_file_read_end_pos(buf, read_start, ret);
                }
-       } while (desc.count && ret);
+       } while (desc->count && ret);
        mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
 
-       return desc.written;
+       return desc->written;
 }
 
 static ssize_t relay_file_read(struct file *filp,
@@ -994,8 +989,13 @@ static ssize_t relay_file_read(struct file *filp,
                               size_t count,
                               loff_t *ppos)
 {
-       return relay_file_read_subbufs(filp, ppos, count, subbuf_read_actor,
-                                      NULL, buffer);
+       read_descriptor_t desc;
+       desc.written = 0;
+       desc.count = count;
+       desc.arg.buf = buffer;
+       desc.error = 0;
+       return relay_file_read_subbufs(filp, ppos, subbuf_read_actor,
+                                      NULL, &desc);
 }
 
 static ssize_t relay_file_sendfile(struct file *filp,
@@ -1004,11 +1004,16 @@ static ssize_t relay_file_sendfile(struct file *filp,
                                   read_actor_t actor,
                                   void *target)
 {
-       return relay_file_read_subbufs(filp, ppos, count, subbuf_send_actor,
-                                      actor, target);
+       read_descriptor_t desc;
+       desc.written = 0;
+       desc.count = count;
+       desc.arg.data = target;
+       desc.error = 0;
+       return relay_file_read_subbufs(filp, ppos, subbuf_send_actor,
+                                      actor, &desc);
 }
 
-struct file_operations relay_file_operations = {
+const struct file_operations relay_file_operations = {
        .open           = relay_file_open,
        .poll           = relay_file_poll,
        .mmap           = relay_file_mmap,