Lines Matching refs:f
88 void msnd_fifo_init(msnd_fifo *f) in msnd_fifo_init() argument
90 f->data = NULL; in msnd_fifo_init()
93 void msnd_fifo_free(msnd_fifo *f) in msnd_fifo_free() argument
95 vfree(f->data); in msnd_fifo_free()
96 f->data = NULL; in msnd_fifo_free()
99 int msnd_fifo_alloc(msnd_fifo *f, size_t n) in msnd_fifo_alloc() argument
101 msnd_fifo_free(f); in msnd_fifo_alloc()
102 f->data = vmalloc(n); in msnd_fifo_alloc()
103 f->n = n; in msnd_fifo_alloc()
104 f->tail = 0; in msnd_fifo_alloc()
105 f->head = 0; in msnd_fifo_alloc()
106 f->len = 0; in msnd_fifo_alloc()
108 if (!f->data) in msnd_fifo_alloc()
114 void msnd_fifo_make_empty(msnd_fifo *f) in msnd_fifo_make_empty() argument
116 f->len = f->tail = f->head = 0; in msnd_fifo_make_empty()
119 int msnd_fifo_write_io(msnd_fifo *f, char __iomem *buf, size_t len) in msnd_fifo_write_io() argument
123 while ((count < len) && (f->len != f->n)) { in msnd_fifo_write_io()
127 if (f->head <= f->tail) { in msnd_fifo_write_io()
129 if (nwritten > f->n - f->tail) in msnd_fifo_write_io()
130 nwritten = f->n - f->tail; in msnd_fifo_write_io()
133 nwritten = f->head - f->tail; in msnd_fifo_write_io()
138 memcpy_fromio(f->data + f->tail, buf, nwritten); in msnd_fifo_write_io()
142 f->len += nwritten; in msnd_fifo_write_io()
143 f->tail += nwritten; in msnd_fifo_write_io()
144 f->tail %= f->n; in msnd_fifo_write_io()
150 int msnd_fifo_write(msnd_fifo *f, const char *buf, size_t len) in msnd_fifo_write() argument
154 while ((count < len) && (f->len != f->n)) { in msnd_fifo_write()
158 if (f->head <= f->tail) { in msnd_fifo_write()
160 if (nwritten > f->n - f->tail) in msnd_fifo_write()
161 nwritten = f->n - f->tail; in msnd_fifo_write()
164 nwritten = f->head - f->tail; in msnd_fifo_write()
169 memcpy(f->data + f->tail, buf, nwritten); in msnd_fifo_write()
173 f->len += nwritten; in msnd_fifo_write()
174 f->tail += nwritten; in msnd_fifo_write()
175 f->tail %= f->n; in msnd_fifo_write()
181 int msnd_fifo_read_io(msnd_fifo *f, char __iomem *buf, size_t len) in msnd_fifo_read_io() argument
185 while ((count < len) && (f->len > 0)) { in msnd_fifo_read_io()
189 if (f->tail <= f->head) { in msnd_fifo_read_io()
191 if (nread > f->n - f->head) in msnd_fifo_read_io()
192 nread = f->n - f->head; in msnd_fifo_read_io()
195 nread = f->tail - f->head; in msnd_fifo_read_io()
200 memcpy_toio(buf, f->data + f->head, nread); in msnd_fifo_read_io()
204 f->len -= nread; in msnd_fifo_read_io()
205 f->head += nread; in msnd_fifo_read_io()
206 f->head %= f->n; in msnd_fifo_read_io()
212 int msnd_fifo_read(msnd_fifo *f, char *buf, size_t len) in msnd_fifo_read() argument
216 while ((count < len) && (f->len > 0)) { in msnd_fifo_read()
220 if (f->tail <= f->head) { in msnd_fifo_read()
222 if (nread > f->n - f->head) in msnd_fifo_read()
223 nread = f->n - f->head; in msnd_fifo_read()
226 nread = f->tail - f->head; in msnd_fifo_read()
231 memcpy(buf, f->data + f->head, nread); in msnd_fifo_read()
235 f->len -= nread; in msnd_fifo_read()
236 f->head += nread; in msnd_fifo_read()
237 f->head %= f->n; in msnd_fifo_read()