From: Tomas Winkler <tomas.winkler@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>,
linux-kernel@vger.kernel.org,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 4/6 RESEND] mei: always copy the read buffer if data is ready
Date: Thu, 7 Jan 2016 14:46:37 +0200 [thread overview]
Message-ID: <1452170799-16960-5-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1452170799-16960-1-git-send-email-tomas.winkler@intel.com>
From: Alexander Usyskin <alexander.usyskin@intel.com>
Copy completed callback content to the user space
if we have such callback ready in the beginning of the read.
Simplify offset processing logic as byproduct.
This is a refinement for:
commit 139aacf757fc ("mei: fix read after read scenario")
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/main.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index b2f2486b3d75..1ee8b492fc4a 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -159,27 +159,22 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
goto out;
}
+ if (ubuf == NULL) {
+ rets = -EMSGSIZE;
+ goto out;
+ }
+
if (cl == &dev->iamthif_cl) {
rets = mei_amthif_read(dev, file, ubuf, length, offset);
goto out;
}
cb = mei_cl_read_cb(cl, file);
- if (cb) {
- /* 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) {
+ if (cb)
+ goto copy_buffer;
+
+ if (*offset > 0)
*offset = 0;
- }
err = mei_cl_read_start(cl, length, file);
if (err && err != -EBUSY) {
@@ -231,10 +226,10 @@ copy_buffer:
goto free;
}
- cl_dbg(dev, cl, "buf.size = %d buf.idx = %ld\n",
- cb->buf.size, cb->buf_idx);
- if (length == 0 || ubuf == NULL || *offset > cb->buf_idx) {
- rets = -EMSGSIZE;
+ cl_dbg(dev, cl, "buf.size = %d buf.idx = %ld offset = %lld\n",
+ cb->buf.size, cb->buf_idx, *offset);
+ if (*offset >= cb->buf_idx) {
+ rets = 0;
goto free;
}
@@ -255,6 +250,7 @@ copy_buffer:
free:
mei_io_cb_free(cb);
+ *offset = 0;
out:
cl_dbg(dev, cl, "end mei read rets = %d\n", rets);
--
2.4.3
next prev parent reply other threads:[~2016-01-07 12:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-07 12:46 [char-misc-next RESEND 0/6] mei updates Tomas Winkler
2016-01-07 12:46 ` [char-misc-next 1/6 RESEND] mei: bus: remove redundant uuid string in debug messages Tomas Winkler
2016-01-07 12:46 ` [char-misc-next 2/6 RESEND] mei: trace pci configuration space io Tomas Winkler
2016-01-07 12:46 ` [char-misc-next 3/6 RESEND] mei: prevent queuing new flow control credit Tomas Winkler
2016-01-07 12:46 ` Tomas Winkler [this message]
2016-01-07 12:46 ` [char-misc-next 5/6 RESEND] mei: fix fasync return value on error Tomas Winkler
2016-01-07 12:46 ` [char-misc-next 6/6 RESEND] mei: drop nfc leftovers from the mei driver Tomas Winkler
2016-01-07 17:31 ` [char-misc-next RESEND 0/6] mei updates Greg Kroah-Hartman
2016-01-07 22:56 ` Winkler, Tomas
2016-01-07 23:08 ` Greg Kroah-Hartman
2016-01-07 23:32 ` Winkler, Tomas
2016-01-08 1:02 ` Greg Kroah-Hartman
2016-01-09 4:59 ` Sudip Mukherjee
2016-01-09 5:10 ` Greg Kroah-Hartman
2016-01-09 5:27 ` Sudip Mukherjee
2016-01-27 21:22 ` Winkler, Tomas
2016-01-27 21:27 ` 'Greg Kroah-Hartman'
2016-01-27 21:33 ` Winkler, Tomas
2016-02-07 6:09 ` Greg Kroah-Hartman
2016-02-07 9:17 ` Winkler, Tomas
2016-02-07 17:33 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452170799-16960-5-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®