diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2013-05-29 20:09:30 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-30 21:44:41 +0900 |
commit | 139aacf757fc89792c43a79ba99bc2361c98ecd3 (patch) | |
tree | cf5c7a8b57e131367bb79d7fa8bd831a6ad39dc4 /drivers | |
parent | 7131799b145aa67984cc57e52d6379862c78afa3 (diff) | |
download | linux-139aacf757fc89792c43a79ba99bc2361c98ecd3.tar.bz2 |
mei: fix read after read scenario
mei read always has to be preceded by write but
'write write read read' scenario should work as well.
In this case the offset is not zero but new read should
be initiated
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/mei/main.c | 24 |
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, goto out; } - if (cl->read_cb && cl->read_cb->buf_idx > *offset) { - cb = cl->read_cb; - goto copy_buffer; - } else if (cl->read_cb && cl->read_cb->buf_idx > 0 && - cl->read_cb->buf_idx <= *offset) { + if (cl->read_cb) { cb = cl->read_cb; - rets = 0; - goto free; - } else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) { - /*Offset needs to be cleaned for contiguous reads*/ + /* read what left */ + if (cb->buf_idx > *offset) + goto copy_buffer; + /* offset is beyond buf_idx we have no more data return 0 */ + if (cb->buf_idx > 0 && cb->buf_idx <= *offset) { + rets = 0; + goto free; + } + /* Offset needs to be cleaned for contiguous reads*/ + if (cb->buf_idx == 0 && *offset > 0) + *offset = 0; + } else if (*offset > 0) { *offset = 0; - rets = 0; - goto out; } err = mei_cl_read_start(cl, length); |