lkml.org 
[lkml]   [2012]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] Input: serio_raw - return error code instead of written on error
On Mon, Jan 9, 2012 at 4:27 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> 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.

Look good to me. Thanks.

> 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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-01-10 09:29    [W:0.054 / U:5.608 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site