Skip to content

Commit 6811a46

Browse files
committed
Merge tag 'tty-5.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial driver fixes from Greg KH: "Here are some small tty n_gsm and serial driver fixes for 5.18-rc7 that resolve reported problems. They include: - n_gsm fixes for reported issues - 8250_mtk driver fixes for some platforms - fsl_lpuart driver fix for reported problem. - digicolor driver fix for reported problem. All have been in linux-next for a while with no reported problems" * tag 'tty-5.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: fsl_lpuart: Don't enable interrupts too early tty: n_gsm: fix invalid gsmtty_write_room() result tty: n_gsm: fix mux activation issues in gsm_config() tty: n_gsm: fix buffer over-read in gsm_dlci_data() serial: 8250_mtk: Fix register address for XON/XOFF character serial: 8250_mtk: Make sure to select the right FEATURE_SEL serial: 8250_mtk: Fix UART_EFR register address tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe()
2 parents fc49583 + 401fb66 commit 6811a46

File tree

4 files changed

+43
-29
lines changed

4 files changed

+43
-29
lines changed

drivers/tty/n_gsm.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ struct gsm_dlci {
137137
int retries;
138138
/* Uplink tty if active */
139139
struct tty_port port; /* The tty bound to this DLCI if there is one */
140+
#define TX_SIZE 4096 /* Must be power of 2. */
140141
struct kfifo fifo; /* Queue fifo for the DLCI */
141142
int adaption; /* Adaption layer in use */
142143
int prev_adaption;
@@ -1658,6 +1659,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
16581659
if (len == 0)
16591660
return;
16601661
}
1662+
len--;
16611663
slen++;
16621664
tty = tty_port_tty_get(port);
16631665
if (tty) {
@@ -1730,7 +1732,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
17301732
return NULL;
17311733
spin_lock_init(&dlci->lock);
17321734
mutex_init(&dlci->mutex);
1733-
if (kfifo_alloc(&dlci->fifo, 4096, GFP_KERNEL) < 0) {
1735+
if (kfifo_alloc(&dlci->fifo, TX_SIZE, GFP_KERNEL) < 0) {
17341736
kfree(dlci);
17351737
return NULL;
17361738
}
@@ -2351,6 +2353,7 @@ static void gsm_copy_config_values(struct gsm_mux *gsm,
23512353

23522354
static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
23532355
{
2356+
int ret = 0;
23542357
int need_close = 0;
23552358
int need_restart = 0;
23562359

@@ -2418,10 +2421,13 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
24182421
* FIXME: We need to separate activation/deactivation from adding
24192422
* and removing from the mux array
24202423
*/
2421-
if (need_restart)
2422-
gsm_activate_mux(gsm);
2423-
if (gsm->initiator && need_close)
2424-
gsm_dlci_begin_open(gsm->dlci[0]);
2424+
if (gsm->dead) {
2425+
ret = gsm_activate_mux(gsm);
2426+
if (ret)
2427+
return ret;
2428+
if (gsm->initiator)
2429+
gsm_dlci_begin_open(gsm->dlci[0]);
2430+
}
24252431
return 0;
24262432
}
24272433

@@ -2971,8 +2977,6 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
29712977
* Virtual tty side
29722978
*/
29732979

2974-
#define TX_SIZE 512
2975-
29762980
/**
29772981
* gsm_modem_upd_via_data - send modem bits via convergence layer
29782982
* @dlci: channel
@@ -3212,7 +3216,7 @@ static unsigned int gsmtty_write_room(struct tty_struct *tty)
32123216
struct gsm_dlci *dlci = tty->driver_data;
32133217
if (dlci->state == DLCI_CLOSED)
32143218
return 0;
3215-
return TX_SIZE - kfifo_len(&dlci->fifo);
3219+
return kfifo_avail(&dlci->fifo);
32163220
}
32173221

32183222
static unsigned int gsmtty_chars_in_buffer(struct tty_struct *tty)

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define MTK_UART_IER_RTSI 0x40 /* Enable RTS Modem status interrupt */
3838
#define MTK_UART_IER_CTSI 0x80 /* Enable CTS Modem status interrupt */
3939

40+
#define MTK_UART_EFR 38 /* I/O: Extended Features Register */
4041
#define MTK_UART_EFR_EN 0x10 /* Enable enhancement feature */
4142
#define MTK_UART_EFR_RTS 0x40 /* Enable hardware rx flow control */
4243
#define MTK_UART_EFR_CTS 0x80 /* Enable hardware tx flow control */
@@ -53,6 +54,12 @@
5354
#define MTK_UART_TX_TRIGGER 1
5455
#define MTK_UART_RX_TRIGGER MTK_UART_RX_SIZE
5556

57+
#define MTK_UART_FEATURE_SEL 39 /* Feature Selection register */
58+
#define MTK_UART_FEAT_NEWRMAP BIT(0) /* Use new register map */
59+
60+
#define MTK_UART_XON1 40 /* I/O: Xon character 1 */
61+
#define MTK_UART_XOFF1 42 /* I/O: Xoff character 1 */
62+
5663
#ifdef CONFIG_SERIAL_8250_DMA
5764
enum dma_rx_status {
5865
DMA_RX_START = 0,
@@ -169,7 +176,7 @@ static void mtk8250_dma_enable(struct uart_8250_port *up)
169176
MTK_UART_DMA_EN_RX | MTK_UART_DMA_EN_TX);
170177

171178
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
172-
serial_out(up, UART_EFR, UART_EFR_ECB);
179+
serial_out(up, MTK_UART_EFR, UART_EFR_ECB);
173180
serial_out(up, UART_LCR, lcr);
174181

175182
if (dmaengine_slave_config(dma->rxchan, &dma->rxconf) != 0)
@@ -232,7 +239,7 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
232239
int lcr = serial_in(up, UART_LCR);
233240

234241
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
235-
serial_out(up, UART_EFR, UART_EFR_ECB);
242+
serial_out(up, MTK_UART_EFR, UART_EFR_ECB);
236243
serial_out(up, UART_LCR, lcr);
237244
lcr = serial_in(up, UART_LCR);
238245

@@ -241,7 +248,7 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
241248
serial_out(up, MTK_UART_ESCAPE_DAT, MTK_UART_ESCAPE_CHAR);
242249
serial_out(up, MTK_UART_ESCAPE_EN, 0x00);
243250
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
244-
serial_out(up, UART_EFR, serial_in(up, UART_EFR) &
251+
serial_out(up, MTK_UART_EFR, serial_in(up, MTK_UART_EFR) &
245252
(~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK)));
246253
serial_out(up, UART_LCR, lcr);
247254
mtk8250_disable_intrs(up, MTK_UART_IER_XOFFI |
@@ -255,8 +262,8 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
255262
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
256263

257264
/*enable hw flow control*/
258-
serial_out(up, UART_EFR, MTK_UART_EFR_HW_FC |
259-
(serial_in(up, UART_EFR) &
265+
serial_out(up, MTK_UART_EFR, MTK_UART_EFR_HW_FC |
266+
(serial_in(up, MTK_UART_EFR) &
260267
(~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))));
261268

262269
serial_out(up, UART_LCR, lcr);
@@ -270,12 +277,12 @@ static void mtk8250_set_flow_ctrl(struct uart_8250_port *up, int mode)
270277
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
271278

272279
/*enable sw flow control */
273-
serial_out(up, UART_EFR, MTK_UART_EFR_XON1_XOFF1 |
274-
(serial_in(up, UART_EFR) &
280+
serial_out(up, MTK_UART_EFR, MTK_UART_EFR_XON1_XOFF1 |
281+
(serial_in(up, MTK_UART_EFR) &
275282
(~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))));
276283

277-
serial_out(up, UART_XON1, START_CHAR(port->state->port.tty));
278-
serial_out(up, UART_XOFF1, STOP_CHAR(port->state->port.tty));
284+
serial_out(up, MTK_UART_XON1, START_CHAR(port->state->port.tty));
285+
serial_out(up, MTK_UART_XOFF1, STOP_CHAR(port->state->port.tty));
279286
serial_out(up, UART_LCR, lcr);
280287
mtk8250_disable_intrs(up, MTK_UART_IER_CTSI|MTK_UART_IER_RTSI);
281288
mtk8250_enable_intrs(up, MTK_UART_IER_XOFFI);
@@ -568,6 +575,10 @@ static int mtk8250_probe(struct platform_device *pdev)
568575
uart.dma = data->dma;
569576
#endif
570577

578+
/* Set AP UART new register map */
579+
writel(MTK_UART_FEAT_NEWRMAP, uart.port.membase +
580+
(MTK_UART_FEATURE_SEL << uart.port.regshift));
581+
571582
/* Disable Rate Fix function */
572583
writel(0x0, uart.port.membase +
573584
(MTK_UART_RATE_FIX << uart.port.regshift));

drivers/tty/serial/digicolor-usart.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,10 @@ static int digicolor_uart_probe(struct platform_device *pdev)
471471
if (IS_ERR(uart_clk))
472472
return PTR_ERR(uart_clk);
473473

474-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
475-
dp->port.mapbase = res->start;
476-
dp->port.membase = devm_ioremap_resource(&pdev->dev, res);
474+
dp->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
477475
if (IS_ERR(dp->port.membase))
478476
return PTR_ERR(dp->port.membase);
477+
dp->port.mapbase = res->start;
479478

480479
irq = platform_get_irq(pdev, 0);
481480
if (irq < 0)

drivers/tty/serial/fsl_lpuart.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,7 @@ static int lpuart_probe(struct platform_device *pdev)
26642664
struct device_node *np = pdev->dev.of_node;
26652665
struct lpuart_port *sport;
26662666
struct resource *res;
2667+
irq_handler_t handler;
26672668
int ret;
26682669

26692670
sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL);
@@ -2741,17 +2742,11 @@ static int lpuart_probe(struct platform_device *pdev)
27412742

27422743
if (lpuart_is_32(sport)) {
27432744
lpuart_reg.cons = LPUART32_CONSOLE;
2744-
ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart32_int, 0,
2745-
DRIVER_NAME, sport);
2745+
handler = lpuart32_int;
27462746
} else {
27472747
lpuart_reg.cons = LPUART_CONSOLE;
2748-
ret = devm_request_irq(&pdev->dev, sport->port.irq, lpuart_int, 0,
2749-
DRIVER_NAME, sport);
2748+
handler = lpuart_int;
27502749
}
2751-
2752-
if (ret)
2753-
goto failed_irq_request;
2754-
27552750
ret = uart_add_one_port(&lpuart_reg, &sport->port);
27562751
if (ret)
27572752
goto failed_attach_port;
@@ -2773,13 +2768,18 @@ static int lpuart_probe(struct platform_device *pdev)
27732768

27742769
sport->port.rs485_config(&sport->port, &sport->port.rs485);
27752770

2771+
ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0,
2772+
DRIVER_NAME, sport);
2773+
if (ret)
2774+
goto failed_irq_request;
2775+
27762776
return 0;
27772777

2778+
failed_irq_request:
27782779
failed_get_rs485:
27792780
failed_reset:
27802781
uart_remove_one_port(&lpuart_reg, &sport->port);
27812782
failed_attach_port:
2782-
failed_irq_request:
27832783
lpuart_disable_clks(sport);
27842784
failed_clock_enable:
27852785
failed_out_of_range:

0 commit comments

Comments
 (0)