mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-25 15:44:13 -06:00
linux: Make sure to close fd on analog/pca9685 init failure
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
674f584190
commit
d222ec1024
2 changed files with 17 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue