summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Shyti <andi@etezian.org>2013-05-28 01:10:26 +0200
committerAndi Shyti <andi@etezian.org>2013-05-28 01:10:26 +0200
commit49638b59b74418511200bd0931c5f502872d7eda (patch)
tree85a2f2ea2f0ba790f345862aba7f40188afe4e67
parentb6dcace1da933bbb74963bc4874aeba71f6cfa79 (diff)
apds990x_proxy: move error handling in gotoHEADmaster
Signed-off-by: Andi Shyti <andi@etezian.org>
-rw-r--r--drivers/misc/apds990x_proxy.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/misc/apds990x_proxy.c b/drivers/misc/apds990x_proxy.c
index cd0c7e4..bcfee83 100644
--- a/drivers/misc/apds990x_proxy.c
+++ b/drivers/misc/apds990x_proxy.c
@@ -87,20 +87,12 @@ int read_proxy(void)
sleep(1);
fd = open(apds990x_dev.prox_raw, O_RDONLY);
- if (fd < 0) {
- retval = errno;
- fprintf(stderr, "%s: %s\n", apds990x_dev.prox_raw,
- strerror(errno));
- return retval;
- }
+ if (fd < 0)
+ goto error;
ret = read(fd, val, sizeof(val));
- if (ret < 0) {
- retval = errno;
- fprintf(stderr, "%s: %s\n",
- apds990x_dev.prox_raw, strerror(errno));
- break;
- }
+ if (ret < 0)
+ goto error;
/* replace EOF with \n */
val[ret-1] = '\n';
@@ -117,6 +109,12 @@ int read_proxy(void)
}
return retval;
+
+error:
+ retval = errno;
+ fprintf(stderr, "%s: %s\n", apds990x_dev.prox_raw, strerror(errno));
+ close(fd);
+ return retval;
}
void print_usage(char *name)