summaryrefslogtreecommitdiffstats
path: root/fs/fifo.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-04-11 13:53:33 +0200
committerJens Axboe <axboe@suse.de>2006-04-11 13:53:33 +0200
commit923f4f23940d2361e8d5c4245982163a8e9d1c91 (patch)
tree05d24681cadfd731a083b0fa3b22b6e7a6622555 /fs/fifo.c
parent9aeedfc4712ed58d9f7ae41596185c72b8dc97e8 (diff)
downloadop-kernel-dev-923f4f23940d2361e8d5c4245982163a8e9d1c91.zip
op-kernel-dev-923f4f23940d2361e8d5c4245982163a8e9d1c91.tar.gz
[PATCH] pipe.c/fifo.c code cleanups
more code cleanups after the macro conversion: - standardize on 'struct pipe_inode_info *pipe' variable names - introduce 'pipe' temporaries to reduce mass inode->i_pipe dereferencing Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'fs/fifo.c')
-rw-r--r--fs/fifo.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/fs/fifo.c b/fs/fifo.c
index 2c27f56..49035b1 100644
--- a/fs/fifo.c
+++ b/fs/fifo.c
@@ -33,14 +33,17 @@ static void wake_up_partner(struct inode* inode)
static int fifo_open(struct inode *inode, struct file *filp)
{
+ struct pipe_inode_info *pipe;
int ret;
mutex_lock(&inode->i_mutex);
- if (!inode->i_pipe) {
+ pipe = inode->i_pipe;
+ if (!pipe) {
ret = -ENOMEM;
- inode->i_pipe = alloc_pipe_info(inode);
- if (!inode->i_pipe)
+ pipe = alloc_pipe_info(inode);
+ if (!pipe)
goto err_nocleanup;
+ inode->i_pipe = pipe;
}
filp->f_version = 0;
@@ -55,18 +58,18 @@ static int fifo_open(struct inode *inode, struct file *filp)
* opened, even when there is no process writing the FIFO.
*/
filp->f_op = &read_fifo_fops;
- inode->i_pipe->r_counter++;
- if (inode->i_pipe->readers++ == 0)
+ pipe->r_counter++;
+ if (pipe->readers++ == 0)
wake_up_partner(inode);
- if (!inode->i_pipe->writers) {
+ if (!pipe->writers) {
if ((filp->f_flags & O_NONBLOCK)) {
/* suppress POLLHUP until we have
* seen a writer */
- filp->f_version = inode->i_pipe->w_counter;
+ filp->f_version = pipe->w_counter;
} else
{
- wait_for_partner(inode, &inode->i_pipe->w_counter);
+ wait_for_partner(inode, &pipe->w_counter);
if(signal_pending(current))
goto err_rd;
}
@@ -80,16 +83,16 @@ static int fifo_open(struct inode *inode, struct file *filp)
* errno=ENXIO when there is no process reading the FIFO.
*/
ret = -ENXIO;
- if ((filp->f_flags & O_NONBLOCK) && !inode->i_pipe->readers)
+ if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
goto err;
filp->f_op = &write_fifo_fops;
- inode->i_pipe->w_counter++;
- if (!inode->i_pipe->writers++)
+ pipe->w_counter++;
+ if (!pipe->writers++)
wake_up_partner(inode);
- if (!inode->i_pipe->readers) {
- wait_for_partner(inode, &inode->i_pipe->r_counter);
+ if (!pipe->readers) {
+ wait_for_partner(inode, &pipe->r_counter);
if (signal_pending(current))
goto err_wr;
}
@@ -104,11 +107,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
*/
filp->f_op = &rdwr_fifo_fops;
- inode->i_pipe->readers++;
- inode->i_pipe->writers++;
- inode->i_pipe->r_counter++;
- inode->i_pipe->w_counter++;
- if (inode->i_pipe->readers == 1 || inode->i_pipe->writers == 1)
+ pipe->readers++;
+ pipe->writers++;
+ pipe->r_counter++;
+ pipe->w_counter++;
+ if (pipe->readers == 1 || pipe->writers == 1)
wake_up_partner(inode);
break;
@@ -122,19 +125,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
return 0;
err_rd:
- if (!--inode->i_pipe->readers)
- wake_up_interruptible(&inode->i_pipe->wait);
+ if (!--pipe->readers)
+ wake_up_interruptible(&pipe->wait);
ret = -ERESTARTSYS;
goto err;
err_wr:
- if (!--inode->i_pipe->writers)
- wake_up_interruptible(&inode->i_pipe->wait);
+ if (!--pipe->writers)
+ wake_up_interruptible(&pipe->wait);
ret = -ERESTARTSYS;
goto err;
err:
- if (!inode->i_pipe->readers && !inode->i_pipe->writers)
+ if (!pipe->readers && !pipe->writers)
free_pipe_info(inode);
err_nocleanup:
OpenPOWER on IntegriCloud