summaryrefslogtreecommitdiffstats
path: root/nuttx/arch/arm
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-07-31 23:45:21 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-07-31 23:45:21 +0000
commit5613fbf73362a2e94ba18c8671669703f77da191 (patch)
tree323f6bd35c6522a6c72895c19f536742f822f54e /nuttx/arch/arm
parent4f4e8123b61339fa053b597f14dd0697b675eebf (diff)
LPC17xx serial now supports minimal termios ioctls; serial driver ioctl methods should not set errno variable
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4994 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch/arm')
-rw-r--r--nuttx/arch/arm/src/c5471/c5471_serial.c10
-rw-r--r--nuttx/arch/arm/src/c5471/c5471_watchdog.c9
-rw-r--r--nuttx/arch/arm/src/calypso/calypso_serial.c6
-rw-r--r--nuttx/arch/arm/src/lm3s/lm3s_serial.c6
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_serial.c207
-rw-r--r--nuttx/arch/arm/src/lpc214x/lpc214x_serial.c6
-rwxr-xr-xnuttx/arch/arm/src/lpc2378/lpc23xx_serial.c7
-rw-r--r--nuttx/arch/arm/src/lpc43xx/lpc43_serial.c6
8 files changed, 157 insertions, 100 deletions
diff --git a/nuttx/arch/arm/src/c5471/c5471_serial.c b/nuttx/arch/arm/src/c5471/c5471_serial.c
index 0e7c53c179..ac86537acb 100644
--- a/nuttx/arch/arm/src/c5471/c5471_serial.c
+++ b/nuttx/arch/arm/src/c5471/c5471_serial.c
@@ -1,8 +1,8 @@
/****************************************************************************
* c5471/c5471_serial.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -625,8 +625,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
struct up_dev_s *user = (struct up_dev_s*)arg;
if (!user)
{
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
+ ret = -EINVAL;
}
else
{
@@ -653,8 +652,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}
diff --git a/nuttx/arch/arm/src/c5471/c5471_watchdog.c b/nuttx/arch/arm/src/c5471/c5471_watchdog.c
index 20b5be97c8..83563def7f 100644
--- a/nuttx/arch/arm/src/c5471/c5471_watchdog.c
+++ b/nuttx/arch/arm/src/c5471/c5471_watchdog.c
@@ -1,8 +1,8 @@
/**************************************************************************
* c5471/c5471_watchdog.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -302,8 +302,7 @@ static int wdt_ioctl(FAR struct file *filp, int cmd, unsigned long arg)
break;
default:
- *get_errno_ptr() = ENOTTY;
- return ERROR;
+ return -ENOTTY;
}
return OK;
@@ -319,7 +318,7 @@ static int wdt_open(struct file *filep)
if (g_wdtopen)
{
- *get_errno_ptr() = EBUSY;
+ return -EBUSY;
}
/* This will automatically load the timer with its max
diff --git a/nuttx/arch/arm/src/calypso/calypso_serial.c b/nuttx/arch/arm/src/calypso/calypso_serial.c
index 69fe26a794..5175d25bbd 100644
--- a/nuttx/arch/arm/src/calypso/calypso_serial.c
+++ b/nuttx/arch/arm/src/calypso/calypso_serial.c
@@ -712,8 +712,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
struct up_dev_s *user = (struct up_dev_s*)arg;
if (!user)
{
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
+ ret = -EINVAL;
}
else
{
@@ -740,8 +739,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}
diff --git a/nuttx/arch/arm/src/lm3s/lm3s_serial.c b/nuttx/arch/arm/src/lm3s/lm3s_serial.c
index 45c388aec9..51f9ce955f 100644
--- a/nuttx/arch/arm/src/lm3s/lm3s_serial.c
+++ b/nuttx/arch/arm/src/lm3s/lm3s_serial.c
@@ -765,8 +765,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
struct up_dev_s *user = (struct up_dev_s*)arg;
if (!user)
{
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
+ ret = -EINVAL;
}
else
{
@@ -776,8 +775,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c
index 10b4a4838d..ced1c5d665 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c
@@ -47,6 +47,9 @@
#include <string.h>
#include <errno.h>
#include <debug.h>
+#ifdef CONFIG_SERIAL_TERMIOS
+# include <termios.h>
+#endif
#include <nuttx/irq.h>
#include <nuttx/arch.h>
@@ -136,14 +139,17 @@ struct uart_ops_s g_uart_ops =
static char g_uart0rxbuffer[CONFIG_UART0_RXBUFSIZE];
static char g_uart0txbuffer[CONFIG_UART0_TXBUFSIZE];
#endif
+
#ifdef CONFIG_LPC17_UART1
static char g_uart1rxbuffer[CONFIG_UART1_RXBUFSIZE];
static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE];
#endif
+
#ifdef CONFIG_LPC17_UART2
static char g_uart2rxbuffer[CONFIG_UART2_RXBUFSIZE];
static char g_uart2txbuffer[CONFIG_UART2_TXBUFSIZE];
#endif
+
#ifdef CONFIG_LPC17_UART3
static char g_uart3rxbuffer[CONFIG_UART3_RXBUFSIZE];
static char g_uart3txbuffer[CONFIG_UART3_TXBUFSIZE];
@@ -273,16 +279,16 @@ static uart_dev_t g_uart3port =
#ifdef HAVE_CONSOLE
# if defined(CONFIG_UART0_SERIAL_CONSOLE)
-# define CONSOLE_DEV g_uart0port /* UART0=console */
-# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
+# define CONSOLE_DEV g_uart0port /* UART0=console */
+# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
# ifdef CONFIG_LPC17_UART1
-# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
+# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
# ifdef CONFIG_LPC17_UART2
-# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
+# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
# ifdef CONFIG_LPC17_UART3
-# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
+# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
# else
-# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
+# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
# endif
# else
# ifdef CONFIG_LPC17_UART3
@@ -294,18 +300,18 @@ static uart_dev_t g_uart3port =
# endif
# else
# ifdef CONFIG_LPC17_UART2
-# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
+# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
# ifdef CONFIG_LPC17_UART3
-# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
+# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
# else
-# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS3_DEV /* No ttyS3 */
# else
# ifdef CONFIG_LPC17_UART3
-# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
+# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
# else
-# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
# endif
# undef TTYS2_DEV /* No ttyS2 */
# undef TTYS3_DEV /* No ttyS3 */
@@ -372,100 +378,100 @@ static uart_dev_t g_uart3port =
# endif
# else
# ifdef CONFIG_LPC17_UART1
-# define TTYS1_DEV g_uart1port /* UART2=ttyS0;UART1=ttyS1 */
+# define TTYS1_DEV g_uart1port /* UART2=ttyS0;UART1=ttyS1 */
# ifdef CONFIG_LPC17_UART3
-# define TTYS2_DEV g_uart3port /* UART2=ttyS0;UART1=ttyS1;UART3=ttyS2 */
+# define TTYS2_DEV g_uart3port /* UART2=ttyS0;UART1=ttyS1;UART3=ttyS2 */
# else
-# undef TTYS2_DEV /* UART2=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS2_DEV /* UART2=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS3_DEV /* No ttyS3 */
# else
# ifdef CONFIG_LPC17_UART3
-# define TTYS1_DEV g_uart3port /* UART2=ttyS0;UART3=ttyS1;No ttyS3 */
+# define TTYS1_DEV g_uart3port /* UART2=ttyS0;UART3=ttyS1;No ttyS3 */
# else
-# undef TTYS1_DEV /* UART2=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS1_DEV /* UART2=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS2_DEV /* No ttyS2 */
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS2_DEV /* No ttyS2 */
+# undef TTYS3_DEV /* No ttyS3 */
# endif
# endif
# elif defined(CONFIG_UART3_SERIAL_CONSOLE)
-# define CONSOLE_DEV g_uart3port /* UART3=console */
-# define TTYS0_DEV g_uart3port /* UART3=ttyS0 */
+# define CONSOLE_DEV g_uart3port /* UART3=console */
+# define TTYS0_DEV g_uart3port /* UART3=ttyS0 */
# ifdef CONFIG_LPC17_UART0
-# define TTYS1_DEV g_uart0port /* UART3=ttyS0;UART0=ttyS1 */
+# define TTYS1_DEV g_uart0port /* UART3=ttyS0;UART0=ttyS1 */
# ifdef CONFIG_LPC17_UART1
-# define TTYS2_DEV g_uart1port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2 */
+# define TTYS2_DEV g_uart1port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2 */
# ifdef CONFIG_LPC17_UART2
-# define TTYS3_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2;UART2=ttyS3 */
+# define TTYS3_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS2;UART2=ttyS3 */
# else
-# undef TTYS3_DEV /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS;No ttyS3 */
+# undef TTYS3_DEV /* UART3=ttyS0;UART0=ttyS1;UART1=ttyS;No ttyS3 */
# endif
# else
# ifdef CONFIG_LPC17_UART2
-# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART2=ttys2;No ttyS3 */
+# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART0=ttyS1;UART2=ttys2;No ttyS3 */
# else
-# undef TTYS2_DEV /* UART3=ttyS0;UART0=ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS2_DEV /* UART3=ttyS0;UART0=ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS3_DEV /* No ttyS3 */
# endif
# else
# ifdef CONFIG_LPC17_UART1
-# define TTYS1_DEV g_uart1port /* UART3=ttyS0;UART1=ttyS1 */
+# define TTYS1_DEV g_uart1port /* UART3=ttyS0;UART1=ttyS1 */
# ifdef CONFIG_LPC17_UART2
-# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART1=ttyS1;UART2=ttyS2;No ttyS3 */
+# define TTYS2_DEV g_uart2port /* UART3=ttyS0;UART1=ttyS1;UART2=ttyS2;No ttyS3 */
# else
-# undef TTYS2_DEV /* UART3=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS2_DEV /* UART3=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS3_DEV /* No ttyS3 */
# else
# ifdef CONFIG_LPC17_UART2
-# define TTYS1_DEV g_uart2port /* UART3=ttyS0;UART2=ttyS1;No ttyS3;No ttyS3 */
-# undef TTYS3_DEV /* UART3=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
+# define TTYS1_DEV g_uart2port /* UART3=ttyS0;UART2=ttyS1;No ttyS3;No ttyS3 */
+# undef TTYS3_DEV /* UART3=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
# else
-# undef TTYS1_DEV /* UART3=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS1_DEV /* UART3=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS2_DEV /* No ttyS2 */
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS2_DEV /* No ttyS2 */
+# undef TTYS3_DEV /* No ttyS3 */
# endif
# endif
# endif
#else /* No console */
-# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
+# define TTYS0_DEV g_uart0port /* UART0=ttyS0 */
# ifdef CONFIG_LPC17_UART1
-# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
+# define TTYS1_DEV g_uart1port /* UART0=ttyS0;UART1=ttyS1 */
# ifdef CONFIG_LPC17_UART2
-# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
+# define TTYS2_DEV g_uart2port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2 */
# ifdef CONFIG_LPC17_UART3
-# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
+# define TTYS3_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS2;UART3=ttyS3 */
# else
-# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
+# undef TTYS3_DEV /* UART0=ttyS0;UART1=ttyS1;UART2=ttyS;No ttyS3 */
# endif
# else
# ifdef CONFIG_LPC17_UART3
-# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART3=ttys2;No ttyS3 */
+# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART1=ttyS1;UART3=ttys2;No ttyS3 */
# else
-# undef TTYS2_DEV /* UART0=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS2_DEV /* UART0=ttyS0;UART1=ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS3_DEV /* No ttyS3 */
# endif
# else
# ifdef CONFIG_LPC17_UART2
-# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
+# define TTYS1_DEV g_uart2port /* UART0=ttyS0;UART2=ttyS1;No ttyS3 */
# ifdef CONFIG_LPC17_UART3
-# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
+# define TTYS2_DEV g_uart3port /* UART0=ttyS0;UART2=ttyS1;UART3=ttyS2;No ttyS3 */
# else
-# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS2_DEV /* UART0=ttyS0;UART2=ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS3_DEV /* No ttyS3 */
# else
# ifdef CONFIG_LPC17_UART3
-# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
+# define TTYS1_DEV g_uart3port /* UART0=ttyS0;UART3=ttyS1;No ttyS2;No ttyS3 */
# else
-# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
+# undef TTYS1_DEV /* UART0=ttyS0;No ttyS1;No ttyS2;No ttyS3 */
# endif
-# undef TTYS2_DEV /* No ttyS2 */
-# undef TTYS3_DEV /* No ttyS3 */
+# undef TTYS2_DEV /* No ttyS2 */
+# undef TTYS3_DEV /* No ttyS3 */
# endif
# endif
#endif /*HAVE_CONSOLE*/
@@ -524,6 +530,7 @@ static inline void up_restoreuartint(struct up_dev_s *priv, uint32_t ier)
static inline void up_enablebreaks(struct up_dev_s *priv, bool enable)
{
uint32_t lcr = up_serialin(priv, LPC17_UART_LCR_OFFSET);
+
if (enable)
{
lcr |= UART_LCR_BRK;
@@ -532,6 +539,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, bool enable)
{
lcr &= ~UART_LCR_BRK;
}
+
up_serialout(priv, LPC17_UART_LCR_OFFSET, lcr);
}
@@ -793,7 +801,6 @@ static inline uint32_t lpc17_uartdl(uint32_t baud, uint8_t divcode)
switch (divcode)
{
-
case SYSCON_PCLKSEL_CCLK4: /* PCLK_peripheral = CCLK/4 */
num = (LPC17_CCLK / 4);
break;
@@ -811,6 +818,7 @@ static inline uint32_t lpc17_uartdl(uint32_t baud, uint8_t divcode)
num = (LPC17_CCLK / 8);
break;
}
+
return num / (baud << 4);
}
@@ -950,6 +958,7 @@ static int up_attach(struct uart_dev_s *dev)
up_enable_irq(priv->irq);
}
+
return ret;
}
@@ -1121,18 +1130,17 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
{
case TIOCSERGSTRUCT:
{
- struct up_dev_s *user = (struct up_dev_s*)arg;
- if (!user)
- {
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
- }
- else
- {
- memcpy(user, dev, sizeof(struct up_dev_s));
- }
- }
- break;
+ struct up_dev_s *user = (struct up_dev_s*)arg;
+ if (!user)
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ memcpy(user, dev, sizeof(struct up_dev_s));
+ }
+ }
+ break;
case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
{
@@ -1151,9 +1159,68 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
}
break;
+#ifdef CONFIG_SERIAL_TERMIOS
+ case TCGETS:
+ {
+ struct termios *termiosp = (struct termios*)arg;
+
+ if (!termiosp)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ /* TODO: Other termios fields are not yet returned.
+ * Note that cfsetospeed is not necessary because we have
+ * knowledge that only one speed is supported.
+ * Both cfset(i|o)speed() translate to cfsetspeed.
+ */
+
+ cfsetispeed(termiosp, priv->baud);
+ }
+ break;
+
+ case TCSETS:
+ {
+ struct termios *termiosp = (struct termios*)arg;
+ uint32_t lcr; /* Holds current values of line control register */
+ uint16_t dl; /* Divisor latch */
+
+ if (!termiosp)
+ {
+ ret = -EINVAL;
+ break;
+ }
+
+ /* TODO: Handle other termios settings.
+ * Note that only cfgetispeed is used because we have knowledge
+ * that only one speed is supported.
+ */
+
+ /* Get the c_speed field in the termios struct */
+
+ priv->baud = cfgetispeed(termiosp);
+
+ /* DLAB open latch */
+
+ lcr = getreg32(priv->uartbase + LPC17_UART_LCR_OFFSET);
+ up_serialout(priv, LPC17_UART_LCR_OFFSET, (lcr | UART_LCR_DLAB));
+
+ /* Set the BAUD divisor */
+
+ dl = lpc17_uartdl(priv->baud, priv->cclkdiv);
+ up_serialout(priv, LPC17_UART_DLM_OFFSET, dl >> 8);
+ up_serialout(priv, LPC17_UART_DLL_OFFSET, dl & 0xff);
+
+ /* Clear DLAB */
+
+ up_serialout(priv, LPC17_UART_LCR_OFFSET, lcr);
+ }
+ break;
+#endif
+
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}
@@ -1201,6 +1268,7 @@ static void up_rxint(struct uart_dev_s *dev, bool enable)
{
priv->ier &= ~UART_IER_RBRIE;
}
+
up_serialout(priv, LPC17_UART_IER_OFFSET, priv->ier);
}
@@ -1264,6 +1332,7 @@ static void up_txint(struct uart_dev_s *dev, bool enable)
priv->ier &= ~UART_IER_THREIE;
up_serialout(priv, LPC17_UART_IER_OFFSET, priv->ier);
}
+
irqrestore(flags);
}
diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c b/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c
index bf7c1ec346..691adfa75e 100644
--- a/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c
+++ b/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c
@@ -574,8 +574,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
struct up_dev_s *user = (struct up_dev_s*)arg;
if (!user)
{
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
+ ret = -EINVAL;
}
else
{
@@ -602,8 +601,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}
diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c
index 69738dae51..4f20cc7fd6 100755
--- a/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c
+++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2010 Rommel Marcelo. All rights reserved.
* Author: Rommel Marcelo
+ * With updates by: Gregory Nutt <gnutt@nuttx.org>
*
* This file is part of the NuttX RTOS and based on the lpc2148 port:
*
@@ -696,8 +697,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
struct up_dev_s *user = (struct up_dev_s *)arg;
if (!user)
{
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
+ ret = -EINVAL;
}
else
{
@@ -726,8 +726,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}
diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c b/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c
index 525cad01d8..6e2e19f355 100644
--- a/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c
+++ b/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c
@@ -1085,8 +1085,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
struct up_dev_s *user = (struct up_dev_s*)arg;
if (!user)
{
- *get_errno_ptr() = EINVAL;
- ret = ERROR;
+ ret = -EINVAL;
}
else
{
@@ -1170,8 +1169,7 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#endif
default:
- *get_errno_ptr() = ENOTTY;
- ret = ERROR;
+ ret = -ENOTTY;
break;
}