Page MenuHomeFreeBSD

Create a mechanism for encoding a system errno into the IIC_Exxxxx space
ClosedPublic

Authored by ian on Jul 16 2019, 7:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 17, 2:08 PM
Unknown Object (File)
Sat, Nov 16, 2:16 AM
Unknown Object (File)
Thu, Nov 14, 12:44 AM
Unknown Object (File)
Oct 3 2024, 10:51 AM
Unknown Object (File)
Oct 2 2024, 8:22 PM
Unknown Object (File)
Oct 1 2024, 1:13 AM
Unknown Object (File)
Sep 26 2024, 8:22 AM
Unknown Object (File)
Sep 25 2024, 5:43 AM
Subscribers

Details

Summary

Errors are communicated between the i2c controller layer and upper layers (iicbus and slave device drivers) using a set of IIC_Exxxxxx constants which effectively define a private number space separate from (and having values that conflict with) the system errno number space. Sometimes it is necessary to report a plain old system error (especially EINTR) from the controller or bus layer and have that value make it back across the syscall interface intact.

I initially considered replicating a few "crucial" errno values with similar names and new numbers, e.g., IIC_EINTR, IIC_ERESTART, etc. It seemed like that had the potential to grow over time until many of the errno names were duplicated into the IIC_Exxxxx space.

So instead, this defines a mechanism to "encode" an errno into the IIC_Exxxx space by setting the high bit and putting the errno into the lower-order bits; a new errno2iic() function does this. The existing iic2errno() recognizes the encoded values and extracts the original errno out of the encoded value. An interesting wrinkle occurs with the pseudo-error values such as ERESTART -- they aleady have the high bit set, and turning it off would be the wrong thing to do. Instead, iic2errno() recognizes that lots of high bits are on (i.e., it's a negative number near to zero) and just returns that value as-is.

Thus, existing drivers continue to work without needing any changes, and there is now a way to return errno values from the lower layers. The first use of that is in iicbus_poll() which does mtx_sleep() with the PCATCH flag, and needs to return the errno from that up the call chain.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 25376