aboutsummaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorJean Cyr <jcyr@dillobits.com>2013-07-07 20:19:27 -0400
committerJean Cyr <jcyr@dillobits.com>2013-07-07 20:19:27 -0400
commit20103f572fcf1451b6625209f02b7fde70dd3f04 (patch)
tree28138193446529e54777af928dc12cbea6bc219d /src/drivers
parentdab652faf68931a2b1fa07609d63518237c9c8b7 (diff)
downloadpx4-firmware-20103f572fcf1451b6625209f02b7fde70dd3f04.tar.gz
px4-firmware-20103f572fcf1451b6625209f02b7fde70dd3f04.tar.bz2
px4-firmware-20103f572fcf1451b6625209f02b7fde70dd3f04.zip
Minor px4io optimization
Since this module creates the PX4IO object and that the IOCTL function doesn't use the file descriptor parameter, there is no need to invoke IOCTL via the filesystem since we can call it directly.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/px4io/px4io.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp
index ad0112b9b..1adefdea5 100644
--- a/src/drivers/px4io/px4io.cpp
+++ b/src/drivers/px4io/px4io.cpp
@@ -1388,7 +1388,8 @@ PX4IO::print_status()
}
int
-PX4IO::ioctl(file *filep, int cmd, unsigned long arg)
+PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg)
+/* Make it obvious that file * isn't used here */
{
int ret = OK;
@@ -1668,11 +1669,7 @@ start(int argc, char *argv[])
if (param_get(param_find("RC_RL1_DSM_VCC"), &dsm_vcc_ctl) == OK) {
if (dsm_vcc_ctl) {
g_dev->set_dsm_vcc_ctl(true);
- int fd = open(GPIO_DEVICE_PATH, O_WRONLY);
- if (fd < 0)
- errx(1, "failed to open device");
- ioctl(fd, DSM_BIND_POWER_UP, 0);
- close(fd);
+ g_dev->ioctl(nullptr, DSM_BIND_POWER_UP, 0);
}
}
exit(0);
@@ -1681,7 +1678,7 @@ start(int argc, char *argv[])
void
bind(int argc, char *argv[])
{
- int fd, pulses;
+ int pulses;
if (g_dev == nullptr)
errx(1, "px4io must be started first");
@@ -1699,12 +1696,7 @@ bind(int argc, char *argv[])
else
errx(1, "unknown parameter %s, use dsm2 or dsmx", argv[2]);
- fd = open(GPIO_DEVICE_PATH, O_WRONLY);
-
- if (fd < 0)
- errx(1, "failed to open device");
-
- ioctl(fd, DSM_BIND_START, pulses);
+ g_dev->ioctl(nullptr, DSM_BIND_START, pulses);
/* Open console directly to grab CTRL-C signal */
int console = open("/dev/console", O_NONBLOCK | O_RDONLY | O_NOCTTY);
@@ -1721,9 +1713,8 @@ bind(int argc, char *argv[])
if (read(console, &c, 1) == 1) {
if (c == 0x03 || c == 0x63) {
warnx("Done\n");
- ioctl(fd, DSM_BIND_STOP, 0);
- ioctl(fd, DSM_BIND_POWER_UP, 0);
- close(fd);
+ g_dev->ioctl(nullptr, DSM_BIND_STOP, 0);
+ g_dev->ioctl(nullptr, DSM_BIND_POWER_UP, 0);
close(console);
exit(0);
}
@@ -1914,7 +1905,7 @@ px4io_main(int argc, char *argv[])
* We can cheat and call the driver directly, as it
* doesn't reference filp in ioctl()
*/
- g_dev->ioctl(NULL, PX4IO_INAIR_RESTART_ENABLE, 1);
+ g_dev->ioctl(nullptr, PX4IO_INAIR_RESTART_ENABLE, 1);
} else {
errx(1, "not loaded");
}
@@ -1958,7 +1949,7 @@ px4io_main(int argc, char *argv[])
/* we can cheat and call the driver directly, as it
* doesn't reference filp in ioctl()
*/
- int ret = g_dev->ioctl(NULL, PX4IO_SET_DEBUG, level);
+ int ret = g_dev->ioctl(nullptr, PX4IO_SET_DEBUG, level);
if (ret != 0) {
printf("SET_DEBUG failed - %d\n", ret);
exit(1);