mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Che-Liang Chiou <clchiou@chromium.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] Input: serio_raw - return error code instead of written on error
Date: Mon, 9 Jan 2012 00:27:45 -0800	[thread overview]
Message-ID: <20120109082745.GD4049@core.coreip.homeip.net> (raw)
In-Reply-To: <1325847795-30486-2-git-send-email-clchiou@chromium.org>

Hi Che-Liang,

On Fri, Jan 06, 2012 at 07:03:15PM +0800, Che-Liang Chiou wrote:
> Even if an error occurs and error code is set, serio_raw_write() returns
> the amount of bytes written anyway.
> 
> If this behavior is actually desirable, serio_raw_write() should not
> even bother to set the error code because it is not intended to be
> returned to the caller.

Thank you for letting me know. The proper behavior is to return number of
bytes successfully written in case of short (or full) transfer, and
return appropriate error in case when we fail to transmit the very first
byte.

I will be applying the patch below.

Thanks.

-- 
Dmitry

Input: serio-raw - return proper result when serio_raw_write fails

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

If serio_raw_write was always returning number of bytes successfully
sent to serio port and never signalled error condition to the caller.
Change it so that for completely failed transfers appropriate error
code returned to the caller (partially successful writes still return
number of bytes transferred).

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

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


diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index c2c6ad8..5d9f9b1 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -224,7 +224,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 
 out:
 	mutex_unlock(&serio_raw_mutex);
-	return written;
+	return written ?: retval;
 }
 
 static unsigned int serio_raw_poll(struct file *file, poll_table *wait)

  reply	other threads:[~2012-01-09  8:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06 11:03 [PATCH 1/2] Input: serio_raw - cosmetic fixes Che-Liang Chiou
2012-01-06 11:03 ` [PATCH 2/2] Input: serio_raw - return error code instead of written on error Che-Liang Chiou
2012-01-09  8:27   ` Dmitry Torokhov [this message]
2012-01-10  8:27     ` Che-liang Chiou
2012-01-09  8:24 ` [PATCH 1/2] Input: serio_raw - cosmetic fixes Dmitry Torokhov
2012-01-10  8:24   ` Che-liang Chiou
2012-01-10  8:39     ` Dmitry Torokhov

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=20120109082745.GD4049@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=clchiou@chromium.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

Powered by JetHome