pipe_lock(pipe);
        ret = 0;
-       if (pipe_empty(pipe->head, pipe->tail))
+       if (pipe_is_empty(pipe))
                goto error_out;
 
        ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
        if (ret < 0)
                goto error_out;
 
-       occupancy = pipe_occupancy(pipe->head, pipe->tail);
+       occupancy = pipe_buf_usage(pipe);
        buf = alloc_buf(port->portdev->vdev, 0, occupancy);
 
        if (!buf) {
 
        if (ret < 0)
                goto out;
 
-       if (pipe_occupancy(pipe->head, pipe->tail) + cs.nr_segs > pipe->max_usage) {
+       if (pipe_buf_usage(pipe) + cs.nr_segs > pipe->max_usage) {
                ret = -EIO;
                goto out;
        }
 
                wake_next_reader = true;
                mutex_lock(&pipe->mutex);
        }
-       if (pipe_empty(pipe->head, pipe->tail))
+       if (pipe_is_empty(pipe))
                wake_next_reader = false;
        mutex_unlock(&pipe->mutex);
 
                kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
                wait_event_interruptible_exclusive(pipe->wr_wait, pipe_writable(pipe));
                mutex_lock(&pipe->mutex);
-               was_empty = pipe_empty(pipe->head, pipe->tail);
+               was_empty = pipe_is_empty(pipe);
                wake_next_writer = true;
        }
 out:
-       if (pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+       if (pipe_is_full(pipe))
                wake_next_writer = false;
        mutex_unlock(&pipe->mutex);
 
 
        int i;
 
        /* Work out how much data we can actually add into the pipe */
-       used = pipe_occupancy(pipe->head, pipe->tail);
+       used = pipe_buf_usage(pipe);
        npages = max_t(ssize_t, pipe->max_usage - used, 0);
        len = min_t(size_t, len, npages * PAGE_SIZE);
        npages = DIV_ROUND_UP(len, PAGE_SIZE);
                return -ERESTARTSYS;
 
 repeat:
-       while (pipe_empty(pipe->head, pipe->tail)) {
+       while (pipe_is_empty(pipe)) {
                if (!pipe->writers)
                        return 0;
 
                if (signal_pending(current))
                        break;
 
-               while (pipe_empty(pipe->head, pipe->tail)) {
+               while (pipe_is_empty(pipe)) {
                        ret = 0;
                        if (!pipe->writers)
                                goto out;
                return 0;
 
        /* Don't try to read more the pipe has space for. */
-       p_space = pipe->max_usage - pipe_occupancy(pipe->head, pipe->tail);
+       p_space = pipe->max_usage - pipe_buf_usage(pipe);
        len = min_t(size_t, len, p_space << PAGE_SHIFT);
 
        if (unlikely(len > MAX_RW_COUNT))
        more = sd->flags & SPLICE_F_MORE;
        sd->flags |= SPLICE_F_MORE;
 
-       WARN_ON_ONCE(!pipe_empty(pipe->head, pipe->tail));
+       WARN_ON_ONCE(!pipe_is_empty(pipe));
 
        while (len) {
                size_t read_len;
                        send_sig(SIGPIPE, current, 0);
                        return -EPIPE;
                }
-               if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+               if (!pipe_is_full(pipe))
                        return 0;
                if (flags & SPLICE_F_NONBLOCK)
                        return -EAGAIN;
         * Check the pipe occupancy without the inode lock first. This function
         * is speculative anyways, so missing one is ok.
         */
-       if (!pipe_empty(pipe->head, pipe->tail))
+       if (!pipe_is_empty(pipe))
                return 0;
 
        ret = 0;
        pipe_lock(pipe);
 
-       while (pipe_empty(pipe->head, pipe->tail)) {
+       while (pipe_is_empty(pipe)) {
                if (signal_pending(current)) {
                        ret = -ERESTARTSYS;
                        break;
         * Check pipe occupancy without the inode lock first. This function
         * is speculative anyways, so missing one is ok.
         */
-       if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+       if (!pipe_is_full(pipe))
                return 0;
 
        ret = 0;
        pipe_lock(pipe);
 
-       while (pipe_full(pipe->head, pipe->tail, pipe->max_usage)) {
+       while (pipe_is_full(pipe)) {
                if (!pipe->readers) {
                        send_sig(SIGPIPE, current, 0);
                        ret = -EPIPE;
 
        return pipe_occupancy(head, tail) >= limit;
 }
 
+/**
+ * pipe_is_full - Return true if the pipe is full
+ * @pipe: the pipe
+ */
+static inline bool pipe_is_full(const struct pipe_inode_info *pipe)
+{
+       return pipe_full(pipe->head, pipe->tail, pipe->max_usage);
+}
+
+/**
+ * pipe_is_empty - Return true if the pipe is empty
+ * @pipe: the pipe
+ */
+static inline bool pipe_is_empty(const struct pipe_inode_info *pipe)
+{
+       return pipe_empty(pipe->head, pipe->tail);
+}
+
+/**
+ * pipe_buf_usage - Return how many pipe buffers are in use
+ * @pipe: the pipe
+ */
+static inline unsigned int pipe_buf_usage(const struct pipe_inode_info *pipe)
+{
+       return pipe_occupancy(pipe->head, pipe->tail);
+}
+
 /**
  * pipe_buf - Return the pipe buffer for the specified slot in the pipe ring
  * @pipe: The pipe to access
 
        size = min(size, folio_size(folio) - offset);
        offset %= PAGE_SIZE;
 
-       while (spliced < size &&
-              !pipe_full(pipe->head, pipe->tail, pipe->max_usage)) {
+       while (spliced < size && !pipe_is_full(pipe)) {
                struct pipe_buffer *buf = pipe_head_buf(pipe);
                size_t part = min_t(size_t, PAGE_SIZE - offset, size - spliced);
 
        iocb.ki_pos = *ppos;
 
        /* Work out how much data we can actually add into the pipe */
-       used = pipe_occupancy(pipe->head, pipe->tail);
+       used = pipe_buf_usage(pipe);
        npages = max_t(ssize_t, pipe->max_usage - used, 0);
        len = min_t(size_t, len, npages * PAGE_SIZE);
 
                        total_spliced += n;
                        *ppos += n;
                        in->f_ra.prev_pos = *ppos;
-                       if (pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+                       if (pipe_is_full(pipe))
                                goto out;
                }
 
 
 
        size = min_t(size_t, size, PAGE_SIZE - offset);
 
-       if (!pipe_full(pipe->head, pipe->tail, pipe->max_usage)) {
+       if (!pipe_is_full(pipe)) {
                struct pipe_buffer *buf = pipe_head_buf(pipe);
 
                *buf = (struct pipe_buffer) {
        int error = 0;
 
        /* Work out how much data we can actually add into the pipe */
-       used = pipe_occupancy(pipe->head, pipe->tail);
+       used = pipe_buf_usage(pipe);
        npages = max_t(ssize_t, pipe->max_usage - used, 0);
        len = min_t(size_t, len, npages * PAGE_SIZE);
 
                total_spliced += n;
                *ppos += n;
                in->f_ra.prev_pos = *ppos;
-               if (pipe_full(pipe->head, pipe->tail, pipe->max_usage))
+               if (pipe_is_full(pipe))
                        break;
 
                cond_resched();