distance sensor drivers: change all open and close to px4_open and px4_close

This commit is contained in:
DanielePettenuzzo 2018-06-22 16:05:24 +02:00 committed by Beat Küng
parent 8f4e9228bf
commit c13d69a610
5 changed files with 31 additions and 31 deletions

View File

@ -761,7 +761,7 @@ start_bus(uint8_t rotation, int i2c_bus)
} }
/* set the poll rate to default, starts automatic data collection */ /* set the poll rate to default, starts automatic data collection */
fd = open(MB12XX_DEVICE_PATH, O_RDONLY); fd = px4_open(MB12XX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
goto fail; goto fail;
@ -771,13 +771,13 @@ start_bus(uint8_t rotation, int i2c_bus)
goto fail; goto fail;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
fail: fail:
if (fd >= 0) { if (fd >= 0) {
close(fd); px4_close(fd);
} }
if (g_dev != nullptr) { if (g_dev != nullptr) {
@ -819,7 +819,7 @@ test()
ssize_t sz; ssize_t sz;
int ret; int ret;
int fd = open(MB12XX_DEVICE_PATH, O_RDONLY); int fd = px4_open(MB12XX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("%s open failed (try 'mb12xx start' if the driver is not running)", MB12XX_DEVICE_PATH); PX4_ERR("%s open failed (try 'mb12xx start' if the driver is not running)", MB12XX_DEVICE_PATH);
@ -883,7 +883,7 @@ test()
int int
reset() reset()
{ {
int fd = open(MB12XX_DEVICE_PATH, O_RDONLY); int fd = px4_open(MB12XX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("failed"); PX4_ERR("failed");
@ -900,7 +900,7 @@ reset()
return PX4_ERROR; return PX4_ERROR;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
} }

View File

@ -713,18 +713,18 @@ start_bus(uint8_t rotation, int i2c_bus)
} }
/* set the poll rate to default, starts automatic data collection */ /* set the poll rate to default, starts automatic data collection */
fd = open(SF1XX_DEVICE_PATH, O_RDONLY); fd = px4_open(SF1XX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
goto fail; goto fail;
} }
if (ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) { if (ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT) < 0) {
::close(fd); px4_close(fd);
goto fail; goto fail;
} }
::close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
fail: fail:
@ -768,7 +768,7 @@ test()
ssize_t sz; ssize_t sz;
int ret; int ret;
int fd = open(SF1XX_DEVICE_PATH, O_RDONLY); int fd = px4_open(SF1XX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("%s open failed (try 'sf1xx start' if the driver is not running)", SF1XX_DEVICE_PATH); PX4_ERR("%s open failed (try 'sf1xx start' if the driver is not running)", SF1XX_DEVICE_PATH);
@ -822,7 +822,7 @@ test()
return PX4_ERROR; return PX4_ERROR;
} }
::close(fd); px4_close(fd);
PX4_INFO("PASS"); PX4_INFO("PASS");
return PX4_OK; return PX4_OK;
@ -834,7 +834,7 @@ test()
int int
reset() reset()
{ {
int fd = open(SF1XX_DEVICE_PATH, O_RDONLY); int fd = px4_open(SF1XX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("failed"); PX4_ERR("failed");
@ -851,7 +851,7 @@ reset()
return PX4_ERROR; return PX4_ERROR;
} }
::close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
} }

View File

@ -764,7 +764,7 @@ start_bus(uint8_t rotation, int i2c_bus)
} }
/* set the poll rate to default, starts automatic data collection */ /* set the poll rate to default, starts automatic data collection */
fd = open(SRF02_DEVICE_PATH, O_RDONLY); fd = px4_open(SRF02_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
goto fail; goto fail;
@ -774,13 +774,13 @@ start_bus(uint8_t rotation, int i2c_bus)
goto fail; goto fail;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
fail: fail:
if (fd >= 0) { if (fd >= 0) {
close(fd); px4_close(fd);
} }
if (g_dev != nullptr) { if (g_dev != nullptr) {
@ -822,7 +822,7 @@ test()
ssize_t sz; ssize_t sz;
int ret; int ret;
int fd = open(SRF02_DEVICE_PATH, O_RDONLY); int fd = px4_open(SRF02_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("%s open failed (try 'srf02 start' if the driver is not running)", SRF02_DEVICE_PATH); PX4_ERR("%s open failed (try 'srf02 start' if the driver is not running)", SRF02_DEVICE_PATH);
@ -886,7 +886,7 @@ test()
int int
reset() reset()
{ {
int fd = open(SRF02_DEVICE_PATH, O_RDONLY); int fd = px4_open(SRF02_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("failed"); PX4_ERR("failed");
@ -903,7 +903,7 @@ reset()
return PX4_ERROR; return PX4_ERROR;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
} }

View File

@ -825,7 +825,7 @@ start_bus(uint8_t rotation, int i2c_bus)
} }
/* set the poll rate to default, starts automatic data collection */ /* set the poll rate to default, starts automatic data collection */
fd = open(TERARANGER_DEVICE_PATH, O_RDONLY); fd = px4_open(TERARANGER_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
goto fail; goto fail;
@ -835,13 +835,13 @@ start_bus(uint8_t rotation, int i2c_bus)
goto fail; goto fail;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
fail: fail:
if (fd >= 0) { if (fd >= 0) {
close(fd); px4_close(fd);
} }
if (g_dev != nullptr) { if (g_dev != nullptr) {
@ -883,7 +883,7 @@ test()
ssize_t sz; ssize_t sz;
int ret; int ret;
int fd = open(TERARANGER_DEVICE_PATH, O_RDONLY); int fd = px4_open(TERARANGER_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("%s open failed (try 'teraranger start' if the driver is not running)", TERARANGER_DEVICE_PATH); PX4_ERR("%s open failed (try 'teraranger start' if the driver is not running)", TERARANGER_DEVICE_PATH);
@ -937,7 +937,7 @@ test()
return PX4_ERROR; return PX4_ERROR;
} }
close(fd); px4_close(fd);
PX4_INFO("PASS"); PX4_INFO("PASS");
return PX4_OK; return PX4_OK;
@ -949,7 +949,7 @@ test()
int int
reset() reset()
{ {
int fd = open(TERARANGER_DEVICE_PATH, O_RDONLY); int fd = px4_open(TERARANGER_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("failed"); PX4_ERR("failed");
@ -966,7 +966,7 @@ reset()
return PX4_ERROR; return PX4_ERROR;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
} }

View File

@ -1044,7 +1044,7 @@ start_bus(uint8_t rotation, int i2c_bus)
} }
/* set the poll rate to default, starts automatic data collection */ /* set the poll rate to default, starts automatic data collection */
fd = open(VL53LXX_DEVICE_PATH, O_RDONLY); fd = px4_open(VL53LXX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
goto fail; goto fail;
@ -1054,13 +1054,13 @@ start_bus(uint8_t rotation, int i2c_bus)
goto fail; goto fail;
} }
close(fd); px4_close(fd);
return PX4_OK; return PX4_OK;
fail: fail:
if (fd >= 0) { if (fd >= 0) {
close(fd); px4_close(fd);
} }
if (g_dev != nullptr) { if (g_dev != nullptr) {
@ -1101,7 +1101,7 @@ test()
struct distance_sensor_s report; struct distance_sensor_s report;
ssize_t sz; ssize_t sz;
int fd = open(VL53LXX_DEVICE_PATH, O_RDONLY); int fd = px4_open(VL53LXX_DEVICE_PATH, O_RDONLY);
if (fd < 0) { if (fd < 0) {
PX4_ERR("%s open failed (try 'vl53lxx start' if the driver is not running)", VL53LXX_DEVICE_PATH); PX4_ERR("%s open failed (try 'vl53lxx start' if the driver is not running)", VL53LXX_DEVICE_PATH);
@ -1118,7 +1118,7 @@ test()
print_message(report); print_message(report);
close(fd); px4_close(fd);
PX4_INFO("PASS"); PX4_INFO("PASS");
return PX4_OK; return PX4_OK;