diff options
author | Jon Ringle <jringle@gridpoint.com> | 2014-04-25 20:11:07 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-05-28 15:22:42 -0400 |
commit | beb04a9f04d95b0d1fdb96719559612705dfc1c9 (patch) | |
tree | b924ec83de2fa5577f30ce636680966889c595b8 | |
parent | 3df5adb23f115a5d2c7ca10fc66a5b9176cedc49 (diff) |
serial: sc16is7xx: dynamically allocate tx/rx buffer
This fixes the warnings:
drivers/tty/serial/sc16is7xx.c: In function 'sc16is7xx_handle_rx':
>> drivers/tty/serial/sc16is7xx.c:548:1: warning: 'sc16is7xx_handle_rx' uses dynamic stack allocation [enabled by default]
drivers/tty/serial/sc16is7xx.c: In function 'sc16is7xx_handle_tx':
>> drivers/tty/serial/sc16is7xx.c:589:1: warning: 'sc16is7xx_handle_tx' uses dynamic stack allocation [enabled by default]
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/sc16is7xx.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 80b0ca68f6e2..1b6a77c4b2cb 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c | |||
@@ -317,6 +317,7 @@ struct sc16is7xx_port { | |||
317 | #ifdef CONFIG_GPIOLIB | 317 | #ifdef CONFIG_GPIOLIB |
318 | struct gpio_chip gpio; | 318 | struct gpio_chip gpio; |
319 | #endif | 319 | #endif |
320 | unsigned char buf[SC16IS7XX_FIFO_SIZE]; | ||
320 | struct sc16is7xx_one p[0]; | 321 | struct sc16is7xx_one p[0]; |
321 | }; | 322 | }; |
322 | 323 | ||
@@ -471,16 +472,15 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen, | |||
471 | { | 472 | { |
472 | struct sc16is7xx_port *s = dev_get_drvdata(port->dev); | 473 | struct sc16is7xx_port *s = dev_get_drvdata(port->dev); |
473 | unsigned int lsr = 0, ch, flag, bytes_read, i; | 474 | unsigned int lsr = 0, ch, flag, bytes_read, i; |
474 | u8 buf[port->fifosize]; | ||
475 | bool read_lsr = (iir == SC16IS7XX_IIR_RLSE_SRC) ? true : false; | 475 | bool read_lsr = (iir == SC16IS7XX_IIR_RLSE_SRC) ? true : false; |
476 | 476 | ||
477 | if (unlikely(rxlen >= port->fifosize)) { | 477 | if (unlikely(rxlen >= sizeof(s->buf))) { |
478 | dev_warn_ratelimited(port->dev, | 478 | dev_warn_ratelimited(port->dev, |
479 | "Port %i: Possible RX FIFO overrun: %d\n", | 479 | "Port %i: Possible RX FIFO overrun: %d\n", |
480 | port->line, rxlen); | 480 | port->line, rxlen); |
481 | port->icount.buf_overrun++; | 481 | port->icount.buf_overrun++; |
482 | /* Ensure sanity of RX level */ | 482 | /* Ensure sanity of RX level */ |
483 | rxlen = port->fifosize; | 483 | rxlen = sizeof(s->buf); |
484 | } | 484 | } |
485 | 485 | ||
486 | while (rxlen) { | 486 | while (rxlen) { |
@@ -493,12 +493,12 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen, | |||
493 | lsr = 0; | 493 | lsr = 0; |
494 | 494 | ||
495 | if (read_lsr) { | 495 | if (read_lsr) { |
496 | buf[0] = sc16is7xx_port_read(port, SC16IS7XX_RHR_REG); | 496 | s->buf[0] = sc16is7xx_port_read(port, SC16IS7XX_RHR_REG); |
497 | bytes_read = 1; | 497 | bytes_read = 1; |
498 | } else { | 498 | } else { |
499 | regcache_cache_bypass(s->regmap, true); | 499 | regcache_cache_bypass(s->regmap, true); |
500 | regmap_raw_read(s->regmap, SC16IS7XX_RHR_REG, | 500 | regmap_raw_read(s->regmap, SC16IS7XX_RHR_REG, |
501 | buf, rxlen); | 501 | s->buf, rxlen); |
502 | regcache_cache_bypass(s->regmap, false); | 502 | regcache_cache_bypass(s->regmap, false); |
503 | bytes_read = rxlen; | 503 | bytes_read = rxlen; |
504 | } | 504 | } |
@@ -532,7 +532,7 @@ static void sc16is7xx_handle_rx(struct uart_port *port, unsigned int rxlen, | |||
532 | } | 532 | } |
533 | 533 | ||
534 | for (i = 0; i < bytes_read; ++i) { | 534 | for (i = 0; i < bytes_read; ++i) { |
535 | ch = buf[i]; | 535 | ch = s->buf[i]; |
536 | if (uart_handle_sysrq_char(port, ch)) | 536 | if (uart_handle_sysrq_char(port, ch)) |
537 | continue; | 537 | continue; |
538 | 538 | ||
@@ -553,7 +553,6 @@ static void sc16is7xx_handle_tx(struct uart_port *port) | |||
553 | struct sc16is7xx_port *s = dev_get_drvdata(port->dev); | 553 | struct sc16is7xx_port *s = dev_get_drvdata(port->dev); |
554 | struct circ_buf *xmit = &port->state->xmit; | 554 | struct circ_buf *xmit = &port->state->xmit; |
555 | unsigned int txlen, to_send, i; | 555 | unsigned int txlen, to_send, i; |
556 | u8 buf[port->fifosize]; | ||
557 | 556 | ||
558 | if (unlikely(port->x_char)) { | 557 | if (unlikely(port->x_char)) { |
559 | sc16is7xx_port_write(port, SC16IS7XX_THR_REG, port->x_char); | 558 | sc16is7xx_port_write(port, SC16IS7XX_THR_REG, port->x_char); |
@@ -577,11 +576,11 @@ static void sc16is7xx_handle_tx(struct uart_port *port) | |||
577 | 576 | ||
578 | /* Convert to linear buffer */ | 577 | /* Convert to linear buffer */ |
579 | for (i = 0; i < to_send; ++i) { | 578 | for (i = 0; i < to_send; ++i) { |
580 | buf[i] = xmit->buf[xmit->tail]; | 579 | s->buf[i] = xmit->buf[xmit->tail]; |
581 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 580 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
582 | } | 581 | } |
583 | regcache_cache_bypass(s->regmap, true); | 582 | regcache_cache_bypass(s->regmap, true); |
584 | regmap_raw_write(s->regmap, SC16IS7XX_THR_REG, buf, to_send); | 583 | regmap_raw_write(s->regmap, SC16IS7XX_THR_REG, s->buf, to_send); |
585 | regcache_cache_bypass(s->regmap, false); | 584 | regcache_cache_bypass(s->regmap, false); |
586 | } | 585 | } |
587 | 586 | ||