serial: Consolidate the general termios in the common place
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
7dfa768552
commit
f987668068
@ -100,7 +100,6 @@ static int usart0_attach(struct uart_dev_s *dev);
|
|||||||
static void usart0_detach(struct uart_dev_s *dev);
|
static void usart0_detach(struct uart_dev_s *dev);
|
||||||
static int usart0_rxinterrupt(int irq, void *context, FAR void *arg);
|
static int usart0_rxinterrupt(int irq, void *context, FAR void *arg);
|
||||||
static int usart0_txinterrupt(int irq, void *context, FAR void *arg);
|
static int usart0_txinterrupt(int irq, void *context, FAR void *arg);
|
||||||
static int usart0_ioctl(struct file *filep, int cmd, unsigned long arg);
|
|
||||||
static int usart0_receive(struct uart_dev_s *dev, FAR unsigned int *status);
|
static int usart0_receive(struct uart_dev_s *dev, FAR unsigned int *status);
|
||||||
static void usart0_rxint(struct uart_dev_s *dev, bool enable);
|
static void usart0_rxint(struct uart_dev_s *dev, bool enable);
|
||||||
static bool usart0_rxavailable(struct uart_dev_s *dev);
|
static bool usart0_rxavailable(struct uart_dev_s *dev);
|
||||||
@ -117,7 +116,6 @@ static int usart1_attach(struct uart_dev_s *dev);
|
|||||||
static void usart1_detach(struct uart_dev_s *dev);
|
static void usart1_detach(struct uart_dev_s *dev);
|
||||||
static int usart1_rxinterrupt(int irq, void *context, FAR void *arg);
|
static int usart1_rxinterrupt(int irq, void *context, FAR void *arg);
|
||||||
static int usart1_txinterrupt(int irq, void *context, FAR void *arg);
|
static int usart1_txinterrupt(int irq, void *context, FAR void *arg);
|
||||||
static int usart1_ioctl(struct file *filep, int cmd, unsigned long arg);
|
|
||||||
static int usart1_receive(struct uart_dev_s *dev, FAR unsigned int *status);
|
static int usart1_receive(struct uart_dev_s *dev, FAR unsigned int *status);
|
||||||
static void usart1_rxint(struct uart_dev_s *dev, bool enable);
|
static void usart1_rxint(struct uart_dev_s *dev, bool enable);
|
||||||
static bool usart1_rxavailable(struct uart_dev_s *dev);
|
static bool usart1_rxavailable(struct uart_dev_s *dev);
|
||||||
@ -140,7 +138,6 @@ struct uart_ops_s g_usart0_ops =
|
|||||||
.shutdown = usart0_shutdown,
|
.shutdown = usart0_shutdown,
|
||||||
.attach = usart0_attach,
|
.attach = usart0_attach,
|
||||||
.detach = usart0_detach,
|
.detach = usart0_detach,
|
||||||
.ioctl = usart0_ioctl,
|
|
||||||
.receive = usart0_receive,
|
.receive = usart0_receive,
|
||||||
.rxint = usart0_rxint,
|
.rxint = usart0_rxint,
|
||||||
.rxavailable = usart0_rxavailable,
|
.rxavailable = usart0_rxavailable,
|
||||||
@ -185,7 +182,6 @@ struct uart_ops_s g_usart1_ops =
|
|||||||
.shutdown = usart1_shutdown,
|
.shutdown = usart1_shutdown,
|
||||||
.attach = usart1_attach,
|
.attach = usart1_attach,
|
||||||
.detach = usart1_detach,
|
.detach = usart1_detach,
|
||||||
.ioctl = usart1_ioctl,
|
|
||||||
.receive = usart1_receive,
|
.receive = usart1_receive,
|
||||||
.rxint = usart1_rxint,
|
.rxint = usart1_rxint,
|
||||||
.rxavailable = usart1_rxavailable,
|
.rxavailable = usart1_rxavailable,
|
||||||
@ -544,62 +540,6 @@ static int usart1_txinterrupt(int irq, void *context, FAR void *arg)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: usart0/1_ioctl
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* All ioctl calls will be routed through this method
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_AVR_USART0
|
|
||||||
static int usart0_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
int ret = OK;
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case TCGETS:
|
|
||||||
case TCSETS:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ret = -ENOTTY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
return -ENOTTY;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_AVR_USART1
|
|
||||||
static int usart1_ioctl(struct file *filep, int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
int ret = OK;
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case TCGETS:
|
|
||||||
case TCSETS:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ret = -ENOTTY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
#else
|
|
||||||
return -ENOTTY;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: usart0/1_receive
|
* Name: usart0/1_receive
|
||||||
*
|
*
|
||||||
|
@ -1439,7 +1439,7 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
#ifdef CONFIG_SERIAL_TERMIOS
|
||||||
/* Append any higher level TTY flags */
|
/* Append any higher level TTY flags */
|
||||||
|
|
||||||
else if (ret == OK)
|
if (ret == OK || ret == -ENOTTY)
|
||||||
{
|
{
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
@ -77,9 +77,6 @@ struct uart_rpmsg_priv_s
|
|||||||
FAR const char *cpuname;
|
FAR const char *cpuname;
|
||||||
FAR void *recv_data;
|
FAR void *recv_data;
|
||||||
bool last_upper;
|
bool last_upper;
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct termios termios;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -90,8 +87,6 @@ static int uart_rpmsg_setup(FAR struct uart_dev_s *dev);
|
|||||||
static void uart_rpmsg_shutdown(FAR struct uart_dev_s *dev);
|
static void uart_rpmsg_shutdown(FAR struct uart_dev_s *dev);
|
||||||
static int uart_rpmsg_attach(FAR struct uart_dev_s *dev);
|
static int uart_rpmsg_attach(FAR struct uart_dev_s *dev);
|
||||||
static void uart_rpmsg_detach(FAR struct uart_dev_s *dev);
|
static void uart_rpmsg_detach(FAR struct uart_dev_s *dev);
|
||||||
static int uart_rpmsg_ioctl(FAR struct file *filep,
|
|
||||||
int cmd, unsigned long arg);
|
|
||||||
static void uart_rpmsg_rxint(FAR struct uart_dev_s *dev, bool enable);
|
static void uart_rpmsg_rxint(FAR struct uart_dev_s *dev, bool enable);
|
||||||
static bool uart_rpmsg_rxflowcontrol(FAR struct uart_dev_s *dev,
|
static bool uart_rpmsg_rxflowcontrol(FAR struct uart_dev_s *dev,
|
||||||
unsigned int nbuffered, bool upper);
|
unsigned int nbuffered, bool upper);
|
||||||
@ -120,7 +115,6 @@ static const struct uart_ops_s g_uart_rpmsg_ops =
|
|||||||
.shutdown = uart_rpmsg_shutdown,
|
.shutdown = uart_rpmsg_shutdown,
|
||||||
.attach = uart_rpmsg_attach,
|
.attach = uart_rpmsg_attach,
|
||||||
.detach = uart_rpmsg_detach,
|
.detach = uart_rpmsg_detach,
|
||||||
.ioctl = uart_rpmsg_ioctl,
|
|
||||||
.rxint = uart_rpmsg_rxint,
|
.rxint = uart_rpmsg_rxint,
|
||||||
.rxflowcontrol = uart_rpmsg_rxflowcontrol,
|
.rxflowcontrol = uart_rpmsg_rxflowcontrol,
|
||||||
.dmasend = uart_rpmsg_dmasend,
|
.dmasend = uart_rpmsg_dmasend,
|
||||||
@ -155,54 +149,6 @@ static void uart_rpmsg_detach(FAR struct uart_dev_s *dev)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static int uart_rpmsg_ioctl(FAR struct file *filep, int cmd,
|
|
||||||
unsigned long arg)
|
|
||||||
{
|
|
||||||
int ret = -ENOTTY;
|
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_TERMIOS
|
|
||||||
struct uart_dev_s *dev = filep->f_inode->i_private;
|
|
||||||
struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
||||||
|
|
||||||
switch (cmd)
|
|
||||||
{
|
|
||||||
case TCGETS:
|
|
||||||
{
|
|
||||||
FAR struct termios *termiosp = (struct termios *)arg;
|
|
||||||
|
|
||||||
if (termiosp)
|
|
||||||
{
|
|
||||||
*termiosp = priv->termios;
|
|
||||||
ret = OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TCSETS:
|
|
||||||
{
|
|
||||||
FAR struct termios *termiosp = (struct termios *)arg;
|
|
||||||
|
|
||||||
if (termiosp)
|
|
||||||
{
|
|
||||||
priv->termios = *termiosp;
|
|
||||||
ret = OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void uart_rpmsg_rxint(FAR struct uart_dev_s *dev, bool enable)
|
static void uart_rpmsg_rxint(FAR struct uart_dev_s *dev, bool enable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user