aboutsummaryrefslogtreecommitdiffstats
path: root/src/linux/analog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/linux/analog.c')
-rw-r--r--src/linux/analog.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/linux/analog.c b/src/linux/analog.c
index c909e286..990f6c4a 100644
--- a/src/linux/analog.c
+++ b/src/linux/analog.c
@@ -26,14 +26,16 @@ gpio_adc_setup(uint8_t pin)
int fd = open(fname, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
report_errno("analog open", fd);
- shutdown("Unable to open adc path");
+ goto fail;
}
int ret = set_non_blocking(fd);
- if (ret < 0) {
- report_errno("analog set_non_blocking", ret);
- shutdown("Unable to set non blocking on adc path");
- }
+ if (ret < 0)
+ goto fail;
return (struct gpio_adc){ .fd = fd };
+fail:
+ if (fd >= 0)
+ close(fd);
+ shutdown("Unable to open adc device");
}
uint32_t