[PATCH 2/3] i2c_tools: Return proper errno from ioctl
Olliver Schinagl
oliver+busybox at schinagl.nl
Fri May 12 08:35:24 UTC 2023
From: Olliver Schinagl <oliver at schinagl.nl>
We shouldn't return -1 (the default error code for the ioctl) but
instead return errno. Our big brother does the same, so we should follow
suit.
Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
---
miscutils/i2c_tools.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 3a7df3b1e..166c9f6bb 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -117,7 +117,10 @@ static int32_t i2c_smbus_access(int fd, char read_write, uint8_t cmd,
args.size = size;
args.data = data;
- return ioctl(fd, I2C_SMBUS, &args);
+ if (ioctl(fd, I2C_SMBUS, &args))
+ return -errno;
+
+ return 0;
}
#if ENABLE_I2CGET || ENABLE_I2CSET || ENABLE_I2CDUMP || ENABLE_I2CDETECT
--
2.40.1
More information about the busybox
mailing list