newton: improve irda driver
authorlyx <lyx@rock-chips.com>
Wed, 31 Aug 2011 06:31:29 +0000 (23:31 -0700)
committerlyx <lyx@rock-chips.com>
Thu, 1 Sep 2011 01:45:51 +0000 (18:45 -0700)
1.improve irda read data effectiveness, reduce overrun err when receiving

drivers/net/irda/ir_serial.c

index 407f58c838aac8efd4f3aca770d795c0de4592ee..e5ae48cea4b90ee0e9e5ce3197ded4bf06661515 100755 (executable)
@@ -112,11 +112,11 @@ static int add_frame_length(struct rev_frame_length *f, unsigned long length)
                return -1;\r
 \r
        f->frame_length[f->iWrite] = length;\r
-       printk("add one frame, length=%ld\n", f->frame_length[f->iWrite]);\r
+       //printk("add one frame, length=%ld\n", f->frame_length[f->iWrite]);\r
        f->iCount++;\r
-       printk("now frame iCount=%d\n", f->iCount);\r
+       //printk("now frame iCount=%d\n", f->iCount);\r
        f->iWrite = (f->iWrite+1) % MAX_FRAME_NUM;\r
-       printk("now frame iWrite=%d\n", f->iWrite);\r
+       //printk("now frame iWrite=%d\n", f->iWrite);\r
        \r
        \r
        return 0;\r
@@ -128,20 +128,21 @@ static int get_frame_length(struct rev_frame_length *f, unsigned long *length)
                return -1;\r
 \r
        *length = f->frame_length[f->iRead];\r
-       printk("read one frame, length=%ld\n", *length);\r
+       //printk("read one frame, length=%ld\n", *length);\r
        f->iCount--;\r
-       printk("now frame iCount=%d\n", f->iCount);\r
+       //printk("now frame iCount=%d\n", f->iCount);\r
        f->iRead = (f->iRead+1) % MAX_FRAME_NUM;\r
-       printk("now frame iRead=%d\n", f->iRead);\r
+       //printk("now frame iRead=%d\n", f->iRead);\r
        \r
        return 0;\r
 }\r
 \r
 static int bu92747_irda_do_rx(struct bu92747_port *s)\r
 {\r
-       int i;\r
-       unsigned int ch, flag;\r
+       //int i;\r
+       //unsigned int ch, flag;\r
        int len;\r
+       struct tty_struct *tty = s->port.state->port.tty;\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
 \r
        if (s->rx_enabled == 0) {\r
@@ -151,6 +152,7 @@ static int bu92747_irda_do_rx(struct bu92747_port *s)
        }\r
        \r
        len = BU92725GUW_get_data(g_receive_buf);\r
+       #if 0\r
        flag = TTY_NORMAL;\r
        //printk("receive data:\n");\r
        for (i=0;i<len;i++) {\r
@@ -160,7 +162,12 @@ static int bu92747_irda_do_rx(struct bu92747_port *s)
                //printk("%d ", ch);\r
        }\r
        //printk("\n");\r
-       \r
+       #else\r
+       if (len > 0) {\r
+               tty_insert_flip_string(tty, g_receive_buf, len);\r
+               s->port.icount.rx += len;\r
+       }\r
+       #endif\r
        return len;\r
  }\r
 \r
@@ -213,7 +220,6 @@ static void bu92747_irda_work(struct work_struct *w)
        struct bu92747_port *s = container_of(w, struct bu92747_port, work);\r
        struct circ_buf *xmit = &s->port.state->xmit;\r
 \r
-       dev_dbg(s->dev, "%s\n", __func__);\r
        printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
 \r
        if (!s->force_end_work && !freezing(current)) {\r
@@ -235,8 +241,6 @@ static irqreturn_t bu92747_irda_irq(int irqno, void *dev_id)
        unsigned long len;\r
        struct rev_frame_length *f = &(s->rev_frames);\r
 \r
-       dev_dbg(s->dev, "%s\n", __func__);\r
-       BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
        irq_src = irda_hw_get_irqsrc();\r
        printk("[%s][%d], 0x%x\n",__FUNCTION__,__LINE__, irq_src);\r
 \r
@@ -303,12 +307,7 @@ static irqreturn_t bu92747_irda_irq(int irqno, void *dev_id)
 \r
 static void bu92747_irda_stop_tx(struct uart_port *port)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 }\r
 \r
 static void bu92747_irda_start_tx(struct uart_port *port)\r
@@ -318,8 +317,6 @@ static void bu92747_irda_start_tx(struct uart_port *port)
                                                  port);\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
 \r
-       dev_dbg(s->dev, "%s\n", __func__);\r
-\r
        //wait for start cmd\r
        if (IS_FIR(s))\r
                return  ;\r
@@ -333,7 +330,6 @@ static void bu92747_irda_stop_rx(struct uart_port *port)
                                                  struct bu92747_port,\r
                                                  port);\r
 \r
-       dev_dbg(s->dev, "%s\n", __func__);\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
 \r
        s->rx_enabled = 0;\r
@@ -348,7 +344,6 @@ static unsigned int bu92747_irda_tx_empty(struct uart_port *port)
                                                  port);\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 \r
        /* may not be truly up-to-date */\r
        //bu92747_irda_dowork(s);\r
@@ -362,19 +357,13 @@ static const char *bu92747_irda_type(struct uart_port *port)
                                                  port);\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 \r
        return s->port.type == PORT_IRDA ? "BU92747" : NULL;\r
 }\r
 \r
 static void bu92747_irda_release_port(struct uart_port *port)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
-\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 }\r
 \r
 static void bu92747_irda_config_port(struct uart_port *port, int flags)\r
@@ -384,7 +373,6 @@ static void bu92747_irda_config_port(struct uart_port *port, int flags)
                                                  port);\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 \r
        if (flags & UART_CONFIG_TYPE)\r
                s->port.type = PORT_IRDA;\r
@@ -393,13 +381,9 @@ static void bu92747_irda_config_port(struct uart_port *port, int flags)
 static int bu92747_irda_verify_port(struct uart_port *port,\r
                                   struct serial_struct *ser)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
        int ret = -EINVAL;\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 \r
        if (ser->type == PORT_UNKNOWN || ser->type == PORT_IRDA)\r
                ret = 0;\r
@@ -415,7 +399,6 @@ static void bu92747_irda_shutdown(struct uart_port *port)
        struct rev_frame_length *f = &(s->rev_frames);\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 \r
        if (s->suspending)\r
                return;\r
@@ -454,7 +437,6 @@ static int bu92747_irda_startup(struct uart_port *port)
        struct rev_frame_length *f = &(s->rev_frames);\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 \r
        s->rx_enabled = 1;\r
        \r
@@ -514,43 +496,22 @@ static int bu92747_irda_startup(struct uart_port *port)
 \r
 static int bu92747_irda_request_port(struct uart_port *port)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
-\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
        return 0;\r
 }\r
 \r
 static void bu92747_irda_break_ctl(struct uart_port *port, int break_state)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
-\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
 }\r
 \r
 static unsigned int bu92747_irda_get_mctrl(struct uart_port *port)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
-\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
-\r
        return  TIOCM_DSR | TIOCM_CAR;\r
 }\r
 \r
 static void bu92747_irda_set_mctrl(struct uart_port *port, unsigned int mctrl)\r
 {\r
-       struct bu92747_port *s = container_of(port,\r
-                                                 struct bu92747_port,\r
-                                                 port);\r
-\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
 }\r
 \r
@@ -566,7 +527,6 @@ bu92747_irda_set_termios(struct uart_port *port, struct ktermios *termios,
        struct tty_struct *tty = s->port.state->port.tty;\r
 \r
        BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
        if (!tty)\r
                return;\r
 \r
@@ -792,8 +752,6 @@ static int bu92747_irda_suspend(struct platform_device *pdev, pm_message_t state
 {\r
        struct bu92747_port *s = dev_get_drvdata(&pdev->dev);\r
 \r
-       dev_dbg(s->dev, "%s\n", __func__);\r
-\r
        if (s->open_flag) {\r
                printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
                disable_irq(s->irq);\r
@@ -812,8 +770,6 @@ static int bu92747_irda_suspend(struct platform_device *pdev, pm_message_t state
 static int bu92747_irda_resume(struct platform_device *pdev)\r
 {\r
        struct bu92747_port *s = dev_get_drvdata(&pdev->dev);\r
-\r
-       dev_dbg(s->dev, "%s\n", __func__);\r
        \r
        if (s->open_flag) {\r
                printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r