Re: [patch 2.6.26-rc-mm] gpio: max732x driver

From: David Brownell
Date: Tue Jul 22 2008 - 06:24:55 EST


On Tuesday 22 July 2008, Andrew Morton wrote:
> > +     if ((mask & chip->dir_input) == 0) {
> > +             dev_dbg(&chip->client->dev, "%s port %d is output only\n",
> > +                     chip->client->name, off);
> > +             return -EACCES;
>
> I don't think that EACCES is a suitable error code here.  That's a
> security/permissions sort of thing.  If userspace is requesting this
> driver to do something which the hardware cannot do then probably
> EINVAL is the appropriate return code.

EINVAL is one of the most ambiguous return codes available. It's
worth avoiding whenever there's *ANY* more meaningful code! In this
case, the gpio_direction_input() call is good about returning that
fault code only for bogus GPIO numbers.

EACCES is what you should get trying to open a write-only file for
reading, which seems like a very direct analogy. That argument is
just fine... it's the particular access request which must be denied,
in this case because hardware itself disallows it rather than a bit
in an inode.

- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/