diff options
-rw-r--r-- | drivers/misc/apds990x_proxy.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/misc/apds990x_proxy.c b/drivers/misc/apds990x_proxy.c index f5e701c..ba6ea3d 100644 --- a/drivers/misc/apds990x_proxy.c +++ b/drivers/misc/apds990x_proxy.c @@ -47,25 +47,30 @@ int write_file(char *fname, const char *val) { int fd; ssize_t ret; + int retval = 0; fd = open(fname, O_WRONLY); if (fd < 0) { + retval = errno; fprintf(stderr, "%s: %s\n", fname, strerror(errno)); - return errno; + return retval; } ret = write(fd, val, 1); if (ret != 1) { + retval = errno; fprintf(stderr, "%s: %s\n", fname, strerror(errno)); close(fd); - return errno; + return retval; } fd = close(fd); - if (fd < 0) + if (fd < 0) { + retval = errno; fprintf(stderr, "%s: %s\n", fname, strerror(errno)); + } - return errno; + return retval; } int read_proxy(void) |