Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F140564293
D20975.id59825.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D20975.id59825.diff
View Options
Index: sys/dev/iicbus/iiconf.h
===================================================================
--- sys/dev/iicbus/iiconf.h
+++ sys/dev/iicbus/iiconf.h
@@ -96,12 +96,14 @@
#define IIC_ENOTSUPP 0x8 /* request not supported */
#define IIC_ENOADDR 0x9 /* no address assigned to the interface */
#define IIC_ERESOURCE 0xa /* resources (memory, whatever) unavailable */
+#define IIC_ERRNO __INT_MIN /* marker bit: errno is in low-order bits */
/*
* Note that all iicbus functions return IIC_Exxxxx status values,
* except iic2errno() (obviously) and iicbus_started() (returns bool).
*/
extern int iic2errno(int);
+extern int errno2iic(int);
extern int iicbus_request_bus(device_t, device_t, int);
extern int iicbus_release_bus(device_t, device_t);
extern device_t iicbus_alloc_bus(device_t);
Index: sys/dev/iicbus/iiconf.c
===================================================================
--- sys/dev/iicbus/iiconf.c
+++ sys/dev/iicbus/iiconf.c
@@ -42,6 +42,18 @@
#include "iicbus_if.h"
/*
+ * Encode a system errno value into the IIC_Exxxxx space by setting the
+ * IIC_ERRNO marker bit, so that iic2errno() can turn it back into a plain
+ * system errno value later. This lets controller- and bus-layer code get
+ * important system errno values (such as EINTR/ERESTART) back to the caller.
+ */
+int
+errno2iic(int errno)
+{
+ return ((errno == 0) ? 0 : errno | IIC_ERRNO);
+}
+
+/*
* Translate IIC_Exxxxx status values to vaguely-equivelent errno values.
*/
int
@@ -59,7 +71,22 @@
case IIC_ENOTSUPP: return (EOPNOTSUPP);
case IIC_ENOADDR: return (EADDRNOTAVAIL);
case IIC_ERESOURCE: return (ENOMEM);
- default: return (EIO);
+ default:
+ /*
+ * If the high bit is set, that means it's a system errno value
+ * that was encoded into the IIC_Exxxxxx space by setting the
+ * IIC_ERRNO marker bit. If lots of high-order bits are set,
+ * then it's one of the negative pseudo-errors such as ERESTART
+ * and we return it as-is. Otherwise it's a plain "small
+ * positive integer" errno, so just remove the IIC_ERRNO marker
+ * bit. If it's some unknown number without the high bit set,
+ * there isn't much we can do except call it an I/O error.
+ */
+ if ((iic_status & IIC_ERRNO) == 0)
+ return (EIO);
+ if ((iic_status & 0xFFFF0000) != 0)
+ return (iic_status);
+ return (iic_status & ~IIC_ERRNO);
}
}
@@ -97,7 +124,7 @@
return (IIC_EBUSBSY);
}
- return (error);
+ return (errno2iic(error));
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 26, 8:12 AM (19 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27278647
Default Alt Text
D20975.id59825.diff (2 KB)
Attached To
Mode
D20975: Create a mechanism for encoding a system errno into the IIC_Exxxxx space
Attached
Detach File
Event Timeline
Log In to Comment