diff --git a/src/drivers/linux_pwm_out/PCA9685.h b/src/drivers/linux_pwm_out/PCA9685.h index d54c263605..71a58275e9 100644 --- a/src/drivers/linux_pwm_out/PCA9685.h +++ b/src/drivers/linux_pwm_out/PCA9685.h @@ -82,7 +82,7 @@ public: */ PCA9685(int bus, int address); - int init() override { return _fd >= 0; } + int init() override { return _fd >= 0 ? 0 : -1; } int send_output_pwm(const uint16_t *pwm, int num_outputs) override; diff --git a/src/drivers/linux_pwm_out/linux_pwm_out.cpp b/src/drivers/linux_pwm_out/linux_pwm_out.cpp index bb1244025a..245c5fc0f2 100644 --- a/src/drivers/linux_pwm_out/linux_pwm_out.cpp +++ b/src/drivers/linux_pwm_out/linux_pwm_out.cpp @@ -217,13 +217,7 @@ void task_main(int argc, char *argv[]) pwm_out = new NavioSysfsPWMOut(_device, _max_num_outputs); } - /** - * if the _protocol is "pca9685" and the driver is executed correctly, - * the return value of "pwm_out->init()" will be higher than 0. - */ - bool check_pwm_device = (strcmp(_protocol, "pca9685") == 0) ? (0 > pwm_out->init()) : (pwm_out->init() != 0); - - if (check_pwm_device) { + if (pwm_out->init() != 0) { PX4_ERR("PWM output init failed"); delete pwm_out; return;