lkml.org 
[lkml]   [2009]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Remove or convert empty ioctls ?
On Thu, 15 Oct 2009 11:35:45 -0400
Jeff Garzik <jeff@garzik.org> wrote:

> On 10/15/2009 11:31 AM, Alan Cox wrote:
> > EINVAL means you used an ioctl that is correct for the driver but that
> > for some reason the driver didn't like it.
>
> Precisely.
>
> The driver author proactively chose to implement the ioctl and return a
> value other than ENOTTY.

Jeff - wake up - take coffee if neeeded.

The case in question is the case where ->unlocked_ioctl() == NULL. In
that case the driver author didn't implement anything and the correct
return from the layer doing the handling is -ENOTTY.

In the case where there is an ioctl handler the common

foo_ioctl()
{
return -EINVAL;
}

stub case is simply broken, and caused by the fact a lot of early Linux
drivers were wrong and people keep propogating mistakes (a serious
problem in the open source world is that most code is produced by copying
stuff but often by copying buggy code).

Essentially the only times you should be returning -EINVAL is where the
driver actually has


case IOCWIBBLE:
/* Do stuff */
if (foo < 1)
return -EINVAL;

All the "I don't know this" cases should be -ENOTTY.

There are cases where

case IOCWIBBLE:
return -EINVAL;

is correct but they are unusual - basically the case where the driver
author wants to "support" the ioctl but there is no argument that it can
be given which is correct.


Anyway the case discussed which is ".unlocked_ioctl = NULL" should return
-ENOTTY, and there isn't any argument about the driver authors intentions.


\
 
 \ /
  Last update: 2009-10-15 17:59    [W:0.057 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site