Lines Matching refs:pipe_ptr

34     struct pipe_t *pipe_ptr = NULL;  in pipe_read()  local
37 pipe_ptr = (struct pipe_t *)file_ptr->private_data; in pipe_read()
38 spin_lock(&pipe_ptr->data.lock); in pipe_read()
39 while (pipe_ptr->data.valid_cnt == 0) in pipe_read()
43 wait_queue_wakeup(&pipe_ptr->data.write_wait_queue, PROC_UNINTERRUPTIBLE); in pipe_read()
44 wait_queue_sleep_on_unlock(&pipe_ptr->data.read_wait_queue, (void *)&pipe_ptr->data.lock); in pipe_read()
45 spin_lock(&pipe_ptr->data.lock); in pipe_read()
47 for (i = 0; i < pipe_ptr->data.valid_cnt; i++) in pipe_read()
53 copy_to_user(buf + i, &pipe_ptr->buf[pipe_ptr->data.read_pos], sizeof(char)); in pipe_read()
54 pipe_ptr->data.read_pos = (pipe_ptr->data.read_pos + 1) % PIPE_BUFF_SIZE; in pipe_read()
56 pipe_ptr->data.valid_cnt = pipe_ptr->data.valid_cnt - i; in pipe_read()
57 spin_unlock(&pipe_ptr->data.lock); in pipe_read()
58 wait_queue_wakeup(&pipe_ptr->data.write_wait_queue, PROC_UNINTERRUPTIBLE); in pipe_read()
67 struct pipe_t *pipe_ptr = NULL; in pipe_write() local
70 pipe_ptr = (struct pipe_t *)file_ptr->private_data; in pipe_write()
71 spin_lock(&pipe_ptr->data.lock); in pipe_write()
72 while (pipe_ptr->data.valid_cnt + count >= PIPE_BUFF_SIZE) in pipe_write()
76 wait_queue_wakeup(&pipe_ptr->data.read_wait_queue, PROC_UNINTERRUPTIBLE); in pipe_write()
77 wait_queue_sleep_on_unlock(&pipe_ptr->data.write_wait_queue, (void *)&pipe_ptr->data.lock); in pipe_write()
78 spin_lock(&pipe_ptr->data.lock); in pipe_write()
80 for (i = pipe_ptr->data.valid_cnt; i < PIPE_BUFF_SIZE; i++) in pipe_write()
82 if (i - pipe_ptr->data.valid_cnt == count) in pipe_write()
86 copy_from_user(&pipe_ptr->buf[pipe_ptr->data.write_pos], buf + i, sizeof(char)); in pipe_write()
87 pipe_ptr->data.write_pos = (pipe_ptr->data.write_pos + 1) % PIPE_BUFF_SIZE; in pipe_write()
89 pipe_ptr->data.valid_cnt += count; in pipe_write()
90 spin_unlock(&pipe_ptr->data.lock); in pipe_write()
91 wait_queue_wakeup(&pipe_ptr->data.read_wait_queue, PROC_UNINTERRUPTIBLE); in pipe_write()
114 struct pipe_t *pipe_ptr = NULL; in pipe_alloc() local
116 pipe_ptr = (struct pipe_t *)kzalloc(sizeof(struct pipe_t), 0); in pipe_alloc()
117 spin_init(&pipe_ptr->data.lock); in pipe_alloc()
118 pipe_ptr->data.read_pos = 0; in pipe_alloc()
119 pipe_ptr->data.write_pos = 0; in pipe_alloc()
120 pipe_ptr->data.valid_cnt = 0; in pipe_alloc()
121 memset(pipe_ptr->buf, 0, PIPE_BUFF_SIZE); in pipe_alloc()
122 wait_queue_init(&pipe_ptr->data.read_wait_queue, NULL); in pipe_alloc()
123 wait_queue_init(&pipe_ptr->data.write_wait_queue, NULL); in pipe_alloc()
125 return pipe_ptr; in pipe_alloc()
138 struct pipe_t *pipe_ptr = NULL; in sys_pipe() local
145 pipe_ptr = pipe_alloc(); in sys_pipe()
152 kfree(pipe_ptr); in sys_pipe()
161 kfree(pipe_ptr); in sys_pipe()
167 read_file->private_data = (void *)pipe_ptr; in sys_pipe()
170 write_file->private_data = (void *)pipe_ptr; in sys_pipe()