industrialio-buffer.c (b5184a26a28fac1d708b0bfeeb958a9260c2924c) industrialio-buffer.c (3da1814184582ed0faf039275a3f02e6f69944ee)
1// SPDX-License-Identifier: GPL-2.0-only
2/* The industrial I/O core
3 *
4 * Copyright (c) 2008 Jonathan Cameron
5 *
6 * Handling of buffer allocation / resizing.
7 *
8 * Things to look at here.

--- 189 unchanged lines hidden (view full) ---

198 return -ENODEV;
199
200 if (!iio_buffer_space_available(rb)) {
201 if (signal_pending(current)) {
202 ret = -ERESTARTSYS;
203 break;
204 }
205
1// SPDX-License-Identifier: GPL-2.0-only
2/* The industrial I/O core
3 *
4 * Copyright (c) 2008 Jonathan Cameron
5 *
6 * Handling of buffer allocation / resizing.
7 *
8 * Things to look at here.

--- 189 unchanged lines hidden (view full) ---

198 return -ENODEV;
199
200 if (!iio_buffer_space_available(rb)) {
201 if (signal_pending(current)) {
202 ret = -ERESTARTSYS;
203 break;
204 }
205
206 if (filp->f_flags & O_NONBLOCK) {
207 if (!written)
208 ret = -EAGAIN;
209 break;
210 }
211
206 wait_woken(&wait, TASK_INTERRUPTIBLE,
207 MAX_SCHEDULE_TIMEOUT);
208 continue;
209 }
210
211 ret = rb->access->write(rb, n - written, buf + written);
212 wait_woken(&wait, TASK_INTERRUPTIBLE,
213 MAX_SCHEDULE_TIMEOUT);
214 continue;
215 }
216
217 ret = rb->access->write(rb, n - written, buf + written);
212 if (ret == 0 && (filp->f_flags & O_NONBLOCK))
213 ret = -EAGAIN;
218 if (ret < 0)
219 break;
214
220
215 if (ret > 0) {
216 written += ret;
217 if (written != n && !(filp->f_flags & O_NONBLOCK))
218 continue;
219 }
220 } while (ret == 0);
221 written += ret;
222
223 } while (written != n);
221 remove_wait_queue(&rb->pollq, &wait);
222
223 return ret < 0 ? ret : written;
224}
225
226/**
227 * iio_buffer_poll() - poll the buffer to find out if it has data
228 * @filp: File structure pointer for device access

--- 1776 unchanged lines hidden ---
224 remove_wait_queue(&rb->pollq, &wait);
225
226 return ret < 0 ? ret : written;
227}
228
229/**
230 * iio_buffer_poll() - poll the buffer to find out if it has data
231 * @filp: File structure pointer for device access

--- 1776 unchanged lines hidden ---