Re: [PATCH] usbhid: replace inappropriate ENOSYS with ENODEV

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 21, 2016 at 6:18 AM, Jiri Kosina <jikos@xxxxxxxxxx> wrote:
> On Wed, 20 Jan 2016, Heiner Kallweit wrote:
>
>> Primary meaning of ENOSYS is "system call not available" but it's also used
>> with meaning "function not implemented". Both are not applicable here.
>>
>> Typically this error occurs when the device was unplugged.
>> usbhid_raw_request returns -ENODEV in such a case what seems to be more
>> reasonable. Therefore use -ENODEV also here.
>>
>> Primary motivation for this change is a change in the LED subsystem to
>> ignore -ENODEV if the device was most likely unplugged.
>
> I believe POSIX defines ENOSYS as "Function not implemented". In this
> case, we are signalling there is no "URB OUT" function.
>

Well, it looks like ENOSYS is really reserved for unimplemented system calls:

commit 91c9afaf97ee554d2cd3042a5ad01ad21c99e8c4
Author: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
Date:   Thu Apr 16 12:44:44 2015 -0700

    checkpatch.pl: new instances of ENOSYS are errors

    ENOSYS means that a nonexistent system call was called.  We have a
    bad habit of using it for things like invalid operations on
    otherwise valid syscalls.  We should avoid this in new code.

    Pervasive incorrect usage of ENOSYS came up at the kernel summit ABI
    review discussion.  Let's see if checkpatch can help.

    I'll submit a separate patch for include/uapi/asm-generic/errno.h.

    Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
    Cc: Pavel Machek <pavel@xxxxxx>
    Cc: Michael Kerrisk <mtk.manpages@xxxxxxxxx>
    Cc: Joe Perches <joe@xxxxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

> I don't have strong preference either way, but ENODEV doesn't seem to be
> particularly good fit for this purpose either.

If there is no urbout during normal operation then -EINVAL I think is
applicable - upper layers are trying to send request to the device
that can not be executed, i.e. invalid request. If it happens during
removal then it is either a) there is a race or b) we are not actually
racing with whomever is resetting urbout to NULL but we need to check
if device is actually gone and return -ENXIO in this case.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux