powerpc: Move spinlock implementation to simple_spinlock
[linux-2.6-microblaze.git] / kernel / relay.c
index d0c9c28..72fe443 100644 (file)
@@ -91,7 +91,7 @@ static void relay_free_page_array(struct page **array)
  *
  *     Returns 0 if ok, negative on error
  *
- *     Caller should already have grabbed mmap_sem.
+ *     Caller should already have grabbed mmap_lock.
  */
 static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
 {
@@ -581,6 +581,11 @@ struct rchan *relay_open(const char *base_filename,
                return NULL;
 
        chan->buf = alloc_percpu(struct rchan_buf *);
+       if (!chan->buf) {
+               kfree(chan);
+               return NULL;
+       }
+
        chan->version = RELAYFS_CHANNEL_VERSION;
        chan->n_subbufs = n_subbufs;
        chan->subbuf_size = subbuf_size;
@@ -991,14 +996,14 @@ static void relay_file_read_consume(struct rchan_buf *buf,
 /*
  *     relay_file_read_avail - boolean, are there unconsumed bytes available?
  */
-static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos)
+static int relay_file_read_avail(struct rchan_buf *buf)
 {
        size_t subbuf_size = buf->chan->subbuf_size;
        size_t n_subbufs = buf->chan->n_subbufs;
        size_t produced = buf->subbufs_produced;
        size_t consumed = buf->subbufs_consumed;
 
-       relay_file_read_consume(buf, read_pos, 0);
+       relay_file_read_consume(buf, 0, 0);
 
        consumed = buf->subbufs_consumed;
 
@@ -1059,23 +1064,20 @@ static size_t relay_file_read_subbuf_avail(size_t read_pos,
 
 /**
  *     relay_file_read_start_pos - find the first available byte to read
- *     @read_pos: file read position
  *     @buf: relay channel buffer
  *
- *     If the @read_pos is in the middle of padding, return the
+ *     If the read_pos is in the middle of padding, return the
  *     position of the first actually available byte, otherwise
  *     return the original value.
  */
-static size_t relay_file_read_start_pos(size_t read_pos,
-                                       struct rchan_buf *buf)
+static size_t relay_file_read_start_pos(struct rchan_buf *buf)
 {
        size_t read_subbuf, padding, padding_start, padding_end;
        size_t subbuf_size = buf->chan->subbuf_size;
        size_t n_subbufs = buf->chan->n_subbufs;
        size_t consumed = buf->subbufs_consumed % n_subbufs;
+       size_t read_pos = consumed * subbuf_size + buf->bytes_consumed;
 
-       if (!read_pos)
-               read_pos = consumed * subbuf_size + buf->bytes_consumed;
        read_subbuf = read_pos / subbuf_size;
        padding = buf->padding[read_subbuf];
        padding_start = (read_subbuf + 1) * subbuf_size - padding;
@@ -1131,10 +1133,10 @@ static ssize_t relay_file_read(struct file *filp,
        do {
                void *from;
 
-               if (!relay_file_read_avail(buf, *ppos))
+               if (!relay_file_read_avail(buf))
                        break;
 
-               read_start = relay_file_read_start_pos(*ppos, buf);
+               read_start = relay_file_read_start_pos(buf);
                avail = relay_file_read_subbuf_avail(read_start, buf);
                if (!avail)
                        break;
@@ -1177,10 +1179,9 @@ static void relay_pipe_buf_release(struct pipe_inode_info *pipe,
 }
 
 static const struct pipe_buf_operations relay_pipe_buf_ops = {
-       .confirm = generic_pipe_buf_confirm,
-       .release = relay_pipe_buf_release,
-       .steal = generic_pipe_buf_steal,
-       .get = generic_pipe_buf_get,
+       .release        = relay_pipe_buf_release,
+       .try_steal      = generic_pipe_buf_try_steal,
+       .get            = generic_pipe_buf_get,
 };
 
 static void relay_page_release(struct splice_pipe_desc *spd, unsigned int i)