* [PATCH] serial/imx: support to handle break character
@ 2011-08-24 9:41 Hui Wang
2011-08-24 15:49 ` Sascha Hauer
2011-08-24 15:50 ` Alan Cox
0 siblings, 2 replies; 3+ messages in thread
From: Hui Wang @ 2011-08-24 9:41 UTC (permalink / raw)
To: gregkh, alan, s.hauer; +Cc: linux-serial
The imx UART hardware controller can identify BREAK character and the
imx_set_termios() can accept BRKINT set by users, but current existing
imx_rxint() can't pass BREAK character and TTY_BREAK to the tty layer
as other serial drivers do (8250.c omap_serial.c).
Here add code to handle BREAK character and pass it to tty layer.
To detect error occurrence, i use URXD_ERR to replace (URXD_OVRRUN |
URXD_FRMERR | ...) because any kind of error occurs, URXD_ERR will
always be set to 1.
I put the URXD_BRK to the first place to check since when BREAK error
occurs, not only URXD_BRK is set to 1, but also URXD_PRERR and
URXD_FRMERR are all set to 1. This arrangement can filter out fake
parity and frame errors when BREAK error occurs.
Signed-off-by: Hui Wang <jason77.wang@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/tty/serial/imx.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 7e91b3d..54ffdc6 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -508,8 +508,10 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
continue;
- if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
- if (rx & URXD_PRERR)
+ if (unlikely(rx & URXD_ERR)) {
+ if (rx & URXD_BRK)
+ sport->port.icount.brk++;
+ else if (rx & URXD_PRERR)
sport->port.icount.parity++;
else if (rx & URXD_FRMERR)
sport->port.icount.frame++;
@@ -524,7 +526,9 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
rx &= sport->port.read_status_mask;
- if (rx & URXD_PRERR)
+ if (rx & URXD_BRK)
+ flg = TTY_BREAK;
+ else if (rx & URXD_PRERR)
flg = TTY_PARITY;
else if (rx & URXD_FRMERR)
flg = TTY_FRAME;
--
1.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] serial/imx: support to handle break character
2011-08-24 9:41 [PATCH] serial/imx: support to handle break character Hui Wang
@ 2011-08-24 15:49 ` Sascha Hauer
2011-08-24 15:50 ` Alan Cox
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2011-08-24 15:49 UTC (permalink / raw)
To: Hui Wang; +Cc: gregkh, alan, linux-serial
On Wed, Aug 24, 2011 at 05:41:47PM +0800, Hui Wang wrote:
> The imx UART hardware controller can identify BREAK character and the
> imx_set_termios() can accept BRKINT set by users, but current existing
> imx_rxint() can't pass BREAK character and TTY_BREAK to the tty layer
> as other serial drivers do (8250.c omap_serial.c).
>
> Here add code to handle BREAK character and pass it to tty layer.
>
> To detect error occurrence, i use URXD_ERR to replace (URXD_OVRRUN |
> URXD_FRMERR | ...) because any kind of error occurs, URXD_ERR will
> always be set to 1.
>
> I put the URXD_BRK to the first place to check since when BREAK error
> occurs, not only URXD_BRK is set to 1, but also URXD_PRERR and
> URXD_FRMERR are all set to 1. This arrangement can filter out fake
> parity and frame errors when BREAK error occurs.
>
> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Alan Cox <alan@linux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/tty/serial/imx.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 7e91b3d..54ffdc6 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -508,8 +508,10 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
> if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
> continue;
>
> - if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
> - if (rx & URXD_PRERR)
> + if (unlikely(rx & URXD_ERR)) {
> + if (rx & URXD_BRK)
> + sport->port.icount.brk++;
> + else if (rx & URXD_PRERR)
> sport->port.icount.parity++;
> else if (rx & URXD_FRMERR)
> sport->port.icount.frame++;
> @@ -524,7 +526,9 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
>
> rx &= sport->port.read_status_mask;
>
> - if (rx & URXD_PRERR)
> + if (rx & URXD_BRK)
> + flg = TTY_BREAK;
> + else if (rx & URXD_PRERR)
> flg = TTY_PARITY;
> else if (rx & URXD_FRMERR)
> flg = TTY_FRAME;
> --
> 1.7.6
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] serial/imx: support to handle break character
2011-08-24 9:41 [PATCH] serial/imx: support to handle break character Hui Wang
2011-08-24 15:49 ` Sascha Hauer
@ 2011-08-24 15:50 ` Alan Cox
1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2011-08-24 15:50 UTC (permalink / raw)
To: Hui Wang; +Cc: gregkh, s.hauer, linux-serial
On Wed, 24 Aug 2011 17:41:47 +0800
Hui Wang <jason77.wang@gmail.com> wrote:
> The imx UART hardware controller can identify BREAK character and the
> imx_set_termios() can accept BRKINT set by users, but current existing
> imx_rxint() can't pass BREAK character and TTY_BREAK to the tty layer
> as other serial drivers do (8250.c omap_serial.c).
>
> Here add code to handle BREAK character and pass it to tty layer.
>
> To detect error occurrence, i use URXD_ERR to replace (URXD_OVRRUN |
> URXD_FRMERR | ...) because any kind of error occurs, URXD_ERR will
> always be set to 1.
>
> I put the URXD_BRK to the first place to check since when BREAK error
> occurs, not only URXD_BRK is set to 1, but also URXD_PRERR and
> URXD_FRMERR are all set to 1. This arrangement can filter out fake
> parity and frame errors when BREAK error occurs.
>
> Signed-off-by: Hui Wang <jason77.wang@gmail.com>
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Alan Cox <alan@linux.intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-24 15:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-24 9:41 [PATCH] serial/imx: support to handle break character Hui Wang
2011-08-24 15:49 ` Sascha Hauer
2011-08-24 15:50 ` Alan Cox
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.