aboutsummaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-01-03 20:42:36 +1100
committerAndrew Tridgell <tridge@samba.org>2013-01-03 20:42:36 +1100
commit73b787a8ddbc0e4d3cb1a5b92b7c6604b5dd6db1 (patch)
treee0029599bb2530edfb8a28201bf752ff04bf9e48 /nuttx
parent3916230d8fc7185a7eefcc1640a68bacf3eac72b (diff)
downloadpx4-firmware-73b787a8ddbc0e4d3cb1a5b92b7c6604b5dd6db1.tar.gz
px4-firmware-73b787a8ddbc0e4d3cb1a5b92b7c6604b5dd6db1.tar.bz2
px4-firmware-73b787a8ddbc0e4d3cb1a5b92b7c6604b5dd6db1.zip
serial: fixed up FIONREAD and FIONWRITE
the device ioctl returns -ENOTTY when it hasn't handled the command
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/drivers/serial/serial.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/nuttx/drivers/serial/serial.c b/nuttx/drivers/serial/serial.c
index 24744524f..71937da74 100644
--- a/nuttx/drivers/serial/serial.c
+++ b/nuttx/drivers/serial/serial.c
@@ -660,9 +660,11 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
int ret = dev->ops->ioctl(filep, cmd, arg);
- /* Append any higher level TTY flags */
-
- if (ret == OK)
+ /*
+ the device ioctl() handler returns -ENOTTY when it doesn't know
+ how to handle the command. Check if we can handle it here.
+ */
+ if (ret == -ENOTTY)
{
switch (cmd)
{
@@ -686,7 +688,9 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
irqrestore(state);
*(int *)arg = count;
+ ret = 0;
}
+ break;
case FIONWRITE:
{
@@ -695,7 +699,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
/* determine the number of bytes free in the buffer */
- if (dev->xmit.head <= dev->xmit.tail)
+ if (dev->xmit.head < dev->xmit.tail)
{
count = dev->xmit.tail - dev->xmit.head - 1;
}
@@ -707,7 +711,9 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
irqrestore(state);
*(int *)arg = count;
+ ret = 0;
}
+ break;
#ifdef CONFIG_SERIAL_TERMIOS
case TCGETS:
@@ -725,6 +731,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
termiosp->c_iflag = dev->tc_iflag;
termiosp->c_oflag = dev->tc_oflag;
termiosp->c_lflag = dev->tc_lflag;
+ ret = 0;
}
break;
@@ -744,6 +751,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
dev->tc_iflag = termiosp->c_iflag;
dev->tc_oflag = termiosp->c_oflag;
dev->tc_lflag = termiosp->c_lflag;
+ ret = 0;
}
break;