On Wed, Mar 2, 2016 at 10:46 PM, Kalowsky, Daniel
-----Original Message-----This is proposal is very similar to what we had done originally for the devices instead of using the DEV_ names.
From: Jesus Sanchez-Palencia [mailto:jesus.sanchez-palencia(a)intel.com]
Sent: Wednesday, March 2, 2016 11:03 AM
To: Guedes, Andre <andre.guedes(a)intel.com>
Subject: [devel] Re: RFC: Use error codes from errno.h
On Thu, 18 Feb 2016 17:47:56 -0200
Andre Guedes <andre.guedes(a)intel.com> wrote:
While we were discussing about adding a new error code for device.h (see
"[RFC] Add DEV_NOT_IMPLEMENTED error code" thread), we had an initial
agreement that it does make sense to use error codes from errno.h
of the ones from include/device.h. Since this topic deserves its own RFC,Cool!
I'm sending this email so we can have a proper discussion.
+1 from my side, mainly so we don't need to discuss the addition of new
error codes ever again :).
So the main points in favor of this change are 1) errno.h is a well-known
error convention which pretty much all developer is familiar with, 2)
errno.h codes address what we need, 3) no need to create new codes such
as DEV_NOT_IMPLEMENTED for instance, and 4) changing the current
to use errno.h codes instead of DEV_* is a feasible task.I would say it's more about 3) and 4) really, as I've seen surprisingly often
how 1) and 2) are not
always true. I've seen recently people getting confused about what to return
and when, myself
included. In the end it doesn't matter from each .h file you get the errors
from, as long as you
have clear guidelines for them, in my opinion.
+1 ! But I would propose that we first get this right for the device driver APIs.
The initial discussion was about using errno.h codes at the driver's layer
but I think we can expand it to the whole system. Actually, errno.h codes
are already used in net/bluetooth and net/ip.
What we have on device.h currently is:
/* Common Error Codes devices can provide */
#define DEV_OK 0 /* No error */
#define DEV_FAIL 1 /* General operation failure */
#define DEV_INVALID_OP 2 /* Invalid operation */
#define DEV_INVALID_CONF 3 /* Invalid configuration */
#define DEV_USED 4 /* Device controller in use */
#define DEV_NO_ACCESS 5 /* Controller not accessible */
#define DEV_NO_SUPPORT 6 /* Device type not supported */
#define DEV_NOT_CONFIG 7 /* Device not configured */
I liked Dirk's suggestion on the previous thread, so I'm gonna propose 2 quick
a- let's try to map each of this to errno codes;
b- let's document when we should return each of them.
You probably have b) ready from the other thread as well, so let me give it a
try with a).
If we get this two right, then we end up with both the guidelines for
documenting and the
transition patch Dirk suggested. After he deprecates DEV_*, moving to errno
codes will be as easy
as a few seds. So:
DEV_OK = 0
DEV_FAIL = (??)
DEV_INVALID_OP = -EPERM or -ENOTSUP (??)ESRCH
DEV_INVALID_CONF = -EINVALENOTSUP
DEV_USED = -EBUSY
DEV_NO_ACCESS = -EAGAIN
DEV_NO_SUPPORT = -ENODEV or -ENXIO (??)
DEV_NOT_CONFIG = (??)EIO
Perhaps ENODEV would fit better since it device related.
DEV_NOT_IMPLEMENTED = -ENOSYS
*this last one is from your previous RFC.
How bad does that look?!
Luiz Augusto von Dentz