mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 03:03:34 +08:00
fix(qurt): Added i2c uninitialize on probe failure to prevent zombie ports
This commit is contained in:
committed by
Eric Katzfey
parent
36006b6d70
commit
02a31d0293
@@ -48,6 +48,10 @@
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/i2c_spi_buses.h>
|
||||
|
||||
extern "C" {
|
||||
__EXPORT void fc_uninitialize_i2c_bus(int fd);
|
||||
}
|
||||
|
||||
namespace device
|
||||
{
|
||||
|
||||
@@ -122,7 +126,7 @@ I2C::init()
|
||||
_i2c_fd = _config_i2c_bus(get_device_bus(), get_device_address(), _frequency);
|
||||
pthread_mutex_unlock(_mutex);
|
||||
|
||||
if (_i2c_fd == PX4_ERROR) {
|
||||
if (_i2c_fd == -1) {
|
||||
PX4_ERR("i2c init failed");
|
||||
goto out;
|
||||
}
|
||||
@@ -132,6 +136,8 @@ I2C::init()
|
||||
|
||||
if (ret != OK) {
|
||||
PX4_ERR("i2c probe failed");
|
||||
fc_uninitialize_i2c_bus(_i2c_fd);
|
||||
_i2c_fd = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user