linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: serio_raw - return proper result when serio_raw_read fails
@ 2012-02-01  8:19 Che-Liang Chiou
  2012-02-08  3:24 ` [PATCH 0/5] Input: serio_raw - add monitor/replay debugging interface Che-Liang Chiou
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Che-Liang Chiou @ 2012-02-01  8:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Che-Liang Chiou, Dmitry Torokhov, linux-input

serio_raw_read now returns (sometimes partially) successful number of
bytes transferred to the caller, and only returns error code to the
caller on completely failed transfers.

Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>
---

I think serio_raw_write() and serio_raw_read() should have the same returning
value behavior.

---
 drivers/input/serio/serio_raw.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 8250299..4494233 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -164,7 +164,8 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
 	struct serio_raw_client *client = file->private_data;
 	struct serio_raw *serio_raw = client->serio_raw;
 	char uninitialized_var(c);
-	ssize_t retval = 0;
+	ssize_t read = 0;
+	int retval;
 
 	if (serio_raw->dead)
 		return -ENODEV;
@@ -180,13 +181,15 @@ static ssize_t serio_raw_read(struct file *file, char __user *buffer,
 	if (serio_raw->dead)
 		return -ENODEV;
 
-	while (retval < count && serio_raw_fetch_byte(serio_raw, &c)) {
-		if (put_user(c, buffer++))
-			return -EFAULT;
-		retval++;
+	while (read < count && serio_raw_fetch_byte(serio_raw, &c)) {
+		if (put_user(c, buffer++)) {
+			retval = -EFAULT;
+			break;
+		}
+		read++;
 	}
 
-	return retval;
+	return read ?: retval;
 }
 
 static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-05-28  9:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01  8:19 [PATCH] Input: serio_raw - return proper result when serio_raw_read fails Che-Liang Chiou
2012-02-08  3:24 ` [PATCH 0/5] Input: serio_raw - add monitor/replay debugging interface Che-Liang Chiou
2012-02-14  3:18   ` Daniel Kurtz
2012-04-21  6:21     ` Dmitry Torokhov
2012-05-28  9:41       ` Che-liang Chiou
2012-02-08  3:24 ` [PATCH 1/5] Input: serio_raw - return proper result when serio_raw_read fails Che-Liang Chiou
2012-02-08  3:24 ` [PATCH 2/5] Input: serio_raw - extract queue interface Che-Liang Chiou
2012-02-08  3:24 ` [PATCH 3/5] Input: serio_raw - factor out common pattern of write Che-Liang Chiou
2012-02-08  3:24 ` [PATCH 4/5] Input: serio_raw - add debugfs interface Che-Liang Chiou
2012-02-08  3:24 ` [PATCH 5/5] Input: serio_raw - implement " Che-Liang Chiou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).