aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/mei/main.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index b9ad5106f5e1..5e11b5b9b65d 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -214,19 +214,21 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
214 goto out; 214 goto out;
215 } 215 }
216 216
217 if (cl->read_cb && cl->read_cb->buf_idx > *offset) { 217 if (cl->read_cb) {
218 cb = cl->read_cb;
219 goto copy_buffer;
220 } else if (cl->read_cb && cl->read_cb->buf_idx > 0 &&
221 cl->read_cb->buf_idx <= *offset) {
222 cb = cl->read_cb; 218 cb = cl->read_cb;
223 rets = 0; 219 /* read what left */
224 goto free; 220 if (cb->buf_idx > *offset)
225 } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) { 221 goto copy_buffer;
226 /*Offset needs to be cleaned for contiguous reads*/ 222 /* offset is beyond buf_idx we have no more data return 0 */
223 if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
224 rets = 0;
225 goto free;
226 }
227 /* Offset needs to be cleaned for contiguous reads*/
228 if (cb->buf_idx == 0 && *offset > 0)
229 *offset = 0;
230 } else if (*offset > 0) {
227 *offset = 0; 231 *offset = 0;
228 rets = 0;
229 goto out;
230 } 232 }
231 233
232 err = mei_cl_read_start(cl, length); 234 err = mei_cl_read_start(cl, length);