Skip to content

Commit cc432ae

Browse files
committed
Merge tag 'tty-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are some small tty/serial fixes for 5.6-rc5 Just some small serial driver fixes, and a vt core fixup, full details are: - vt fixes for issues found by syzbot - serdev fix for Apple boxes - fsl_lpuart serial driver fixes - MAINTAINER update for incorrect serial files - new device ids for 8250_exar driver - mvebu-uart fix All of these have been in linux-next with no reported issues" * tag 'tty-5.6-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: tty: serial: fsl_lpuart: free IDs allocated by IDA Revert "tty: serial: fsl_lpuart: drop EARLYCON_DECLARE" serdev: Fix detection of UART devices on Apple machines. MAINTAINERS: Add missed files related to Synopsys DesignWare UART serial: 8250_exar: add support for ACCES cards tty:serial:mvebu-uart:fix a wrong return vt: selection, push sel_lock up vt: selection, push console lock down
2 parents fd3f6cc + 2b2e71f commit cc432ae

File tree

8 files changed

+90
-29
lines changed

8 files changed

+90
-29
lines changed

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16080,6 +16080,8 @@ SYNOPSYS DESIGNWARE 8250 UART DRIVER
1608016080
R: Andy Shevchenko <[email protected]>
1608116081
S: Maintained
1608216082
F: drivers/tty/serial/8250/8250_dw.c
16083+
F: drivers/tty/serial/8250/8250_dwlib.*
16084+
F: drivers/tty/serial/8250/8250_lpss.c
1608316085

1608416086
SYNOPSYS DESIGNWARE APB GPIO DRIVER
1608516087
M: Hoan Tran <[email protected]>

drivers/staging/speakup/selection.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ static void __speakup_set_selection(struct work_struct *work)
5151
goto unref;
5252
}
5353

54-
console_lock();
5554
set_selection_kernel(&sel, tty);
56-
console_unlock();
5755

5856
unref:
5957
tty_kref_put(tty);

drivers/tty/serdev/core.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/sched.h>
1919
#include <linux/serdev.h>
2020
#include <linux/slab.h>
21+
#include <linux/platform_data/x86/apple.h>
2122

2223
static bool is_registered;
2324
static DEFINE_IDA(ctrl_ida);
@@ -631,6 +632,15 @@ static int acpi_serdev_check_resources(struct serdev_controller *ctrl,
631632
if (ret)
632633
return ret;
633634

635+
/*
636+
* Apple machines provide an empty resource template, so on those
637+
* machines just look for immediate children with a "baud" property
638+
* (from the _DSM method) instead.
639+
*/
640+
if (!lookup.controller_handle && x86_apple_machine &&
641+
!acpi_dev_get_property(adev, "baud", ACPI_TYPE_BUFFER, NULL))
642+
acpi_get_parent(adev->handle, &lookup.controller_handle);
643+
634644
/* Make sure controller and ResourceSource handle match */
635645
if (ACPI_HANDLE(ctrl->dev.parent) != lookup.controller_handle)
636646
return -ENODEV;

drivers/tty/serial/8250/8250_exar.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525

2626
#include "8250.h"
2727

28+
#define PCI_DEVICE_ID_ACCES_COM_2S 0x1052
29+
#define PCI_DEVICE_ID_ACCES_COM_4S 0x105d
30+
#define PCI_DEVICE_ID_ACCES_COM_8S 0x106c
31+
#define PCI_DEVICE_ID_ACCES_COM232_8 0x10a8
32+
#define PCI_DEVICE_ID_ACCES_COM_2SM 0x10d2
33+
#define PCI_DEVICE_ID_ACCES_COM_4SM 0x10db
34+
#define PCI_DEVICE_ID_ACCES_COM_8SM 0x10ea
35+
2836
#define PCI_DEVICE_ID_COMMTECH_4224PCI335 0x0002
2937
#define PCI_DEVICE_ID_COMMTECH_4222PCI335 0x0004
3038
#define PCI_DEVICE_ID_COMMTECH_2324PCI335 0x000a
@@ -677,6 +685,22 @@ static int __maybe_unused exar_resume(struct device *dev)
677685

678686
static SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);
679687

688+
static const struct exar8250_board acces_com_2x = {
689+
.num_ports = 2,
690+
.setup = pci_xr17c154_setup,
691+
};
692+
693+
static const struct exar8250_board acces_com_4x = {
694+
.num_ports = 4,
695+
.setup = pci_xr17c154_setup,
696+
};
697+
698+
static const struct exar8250_board acces_com_8x = {
699+
.num_ports = 8,
700+
.setup = pci_xr17c154_setup,
701+
};
702+
703+
680704
static const struct exar8250_board pbn_fastcom335_2 = {
681705
.num_ports = 2,
682706
.setup = pci_fastcom335_setup,
@@ -745,6 +769,15 @@ static const struct exar8250_board pbn_exar_XR17V8358 = {
745769
}
746770

747771
static const struct pci_device_id exar_pci_tbl[] = {
772+
EXAR_DEVICE(ACCESSIO, ACCES_COM_2S, acces_com_2x),
773+
EXAR_DEVICE(ACCESSIO, ACCES_COM_4S, acces_com_4x),
774+
EXAR_DEVICE(ACCESSIO, ACCES_COM_8S, acces_com_8x),
775+
EXAR_DEVICE(ACCESSIO, ACCES_COM232_8, acces_com_8x),
776+
EXAR_DEVICE(ACCESSIO, ACCES_COM_2SM, acces_com_2x),
777+
EXAR_DEVICE(ACCESSIO, ACCES_COM_4SM, acces_com_4x),
778+
EXAR_DEVICE(ACCESSIO, ACCES_COM_8SM, acces_com_8x),
779+
780+
748781
CONNECT_DEVICE(XR17C152, UART_2_232, pbn_connect),
749782
CONNECT_DEVICE(XR17C154, UART_4_232, pbn_connect),
750783
CONNECT_DEVICE(XR17C158, UART_8_232, pbn_connect),

drivers/tty/serial/fsl_lpuart.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ struct lpuart_port {
264264
int rx_dma_rng_buf_len;
265265
unsigned int dma_tx_nents;
266266
wait_queue_head_t dma_wait;
267+
bool id_allocated;
267268
};
268269

269270
struct lpuart_soc_data {
@@ -2390,6 +2391,8 @@ static int __init lpuart32_imx_early_console_setup(struct earlycon_device *devic
23902391
OF_EARLYCON_DECLARE(lpuart, "fsl,vf610-lpuart", lpuart_early_console_setup);
23912392
OF_EARLYCON_DECLARE(lpuart32, "fsl,ls1021a-lpuart", lpuart32_early_console_setup);
23922393
OF_EARLYCON_DECLARE(lpuart32, "fsl,imx7ulp-lpuart", lpuart32_imx_early_console_setup);
2394+
EARLYCON_DECLARE(lpuart, lpuart_early_console_setup);
2395+
EARLYCON_DECLARE(lpuart32, lpuart32_early_console_setup);
23932396

23942397
#define LPUART_CONSOLE (&lpuart_console)
23952398
#define LPUART32_CONSOLE (&lpuart32_console)
@@ -2420,19 +2423,6 @@ static int lpuart_probe(struct platform_device *pdev)
24202423
if (!sport)
24212424
return -ENOMEM;
24222425

2423-
ret = of_alias_get_id(np, "serial");
2424-
if (ret < 0) {
2425-
ret = ida_simple_get(&fsl_lpuart_ida, 0, UART_NR, GFP_KERNEL);
2426-
if (ret < 0) {
2427-
dev_err(&pdev->dev, "port line is full, add device failed\n");
2428-
return ret;
2429-
}
2430-
}
2431-
if (ret >= ARRAY_SIZE(lpuart_ports)) {
2432-
dev_err(&pdev->dev, "serial%d out of range\n", ret);
2433-
return -EINVAL;
2434-
}
2435-
sport->port.line = ret;
24362426
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
24372427
sport->port.membase = devm_ioremap_resource(&pdev->dev, res);
24382428
if (IS_ERR(sport->port.membase))
@@ -2477,9 +2467,25 @@ static int lpuart_probe(struct platform_device *pdev)
24772467
}
24782468
}
24792469

2470+
ret = of_alias_get_id(np, "serial");
2471+
if (ret < 0) {
2472+
ret = ida_simple_get(&fsl_lpuart_ida, 0, UART_NR, GFP_KERNEL);
2473+
if (ret < 0) {
2474+
dev_err(&pdev->dev, "port line is full, add device failed\n");
2475+
return ret;
2476+
}
2477+
sport->id_allocated = true;
2478+
}
2479+
if (ret >= ARRAY_SIZE(lpuart_ports)) {
2480+
dev_err(&pdev->dev, "serial%d out of range\n", ret);
2481+
ret = -EINVAL;
2482+
goto failed_out_of_range;
2483+
}
2484+
sport->port.line = ret;
2485+
24802486
ret = lpuart_enable_clks(sport);
24812487
if (ret)
2482-
return ret;
2488+
goto failed_clock_enable;
24832489
sport->port.uartclk = lpuart_get_baud_clk_rate(sport);
24842490

24852491
lpuart_ports[sport->port.line] = sport;
@@ -2529,6 +2535,10 @@ static int lpuart_probe(struct platform_device *pdev)
25292535
failed_attach_port:
25302536
failed_irq_request:
25312537
lpuart_disable_clks(sport);
2538+
failed_clock_enable:
2539+
failed_out_of_range:
2540+
if (sport->id_allocated)
2541+
ida_simple_remove(&fsl_lpuart_ida, sport->port.line);
25322542
return ret;
25332543
}
25342544

@@ -2538,7 +2548,8 @@ static int lpuart_remove(struct platform_device *pdev)
25382548

25392549
uart_remove_one_port(&lpuart_reg, &sport->port);
25402550

2541-
ida_simple_remove(&fsl_lpuart_ida, sport->port.line);
2551+
if (sport->id_allocated)
2552+
ida_simple_remove(&fsl_lpuart_ida, sport->port.line);
25422553

25432554
lpuart_disable_clks(sport);
25442555

drivers/tty/serial/mvebu-uart.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ static int mvebu_uart_probe(struct platform_device *pdev)
851851

852852
port->membase = devm_ioremap_resource(&pdev->dev, reg);
853853
if (IS_ERR(port->membase))
854-
return -PTR_ERR(port->membase);
854+
return PTR_ERR(port->membase);
855855

856856
mvuart = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_uart),
857857
GFP_KERNEL);

drivers/tty/vt/selection.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ int set_selection_user(const struct tiocl_selection __user *sel,
181181
return set_selection_kernel(&v, tty);
182182
}
183183

184-
int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
184+
static int __set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
185185
{
186186
struct vc_data *vc = vc_cons[fg_console].d;
187187
int new_sel_start, new_sel_end, spc;
@@ -214,7 +214,6 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
214214
if (ps > pe) /* make sel_start <= sel_end */
215215
swap(ps, pe);
216216

217-
mutex_lock(&sel_lock);
218217
if (sel_cons != vc_cons[fg_console].d) {
219218
clear_selection();
220219
sel_cons = vc_cons[fg_console].d;
@@ -260,10 +259,9 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
260259
break;
261260
case TIOCL_SELPOINTER:
262261
highlight_pointer(pe);
263-
goto unlock;
262+
return 0;
264263
default:
265-
ret = -EINVAL;
266-
goto unlock;
264+
return -EINVAL;
267265
}
268266

269267
/* remove the pointer */
@@ -285,7 +283,7 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
285283
else if (new_sel_start == sel_start)
286284
{
287285
if (new_sel_end == sel_end) /* no action required */
288-
goto unlock;
286+
return 0;
289287
else if (new_sel_end > sel_end) /* extend to right */
290288
highlight(sel_end + 2, new_sel_end);
291289
else /* contract from right */
@@ -313,8 +311,7 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
313311
if (!bp) {
314312
printk(KERN_WARNING "selection: kmalloc() failed\n");
315313
clear_selection();
316-
ret = -ENOMEM;
317-
goto unlock;
314+
return -ENOMEM;
318315
}
319316
kfree(sel_buffer);
320317
sel_buffer = bp;
@@ -339,8 +336,20 @@ int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
339336
}
340337
}
341338
sel_buffer_lth = bp - sel_buffer;
342-
unlock:
339+
340+
return ret;
341+
}
342+
343+
int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty)
344+
{
345+
int ret;
346+
347+
mutex_lock(&sel_lock);
348+
console_lock();
349+
ret = __set_selection_kernel(v, tty);
350+
console_unlock();
343351
mutex_unlock(&sel_lock);
352+
344353
return ret;
345354
}
346355
EXPORT_SYMBOL_GPL(set_selection_kernel);

drivers/tty/vt/vt.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,10 +3046,8 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
30463046
switch (type)
30473047
{
30483048
case TIOCL_SETSEL:
3049-
console_lock();
30503049
ret = set_selection_user((struct tiocl_selection
30513050
__user *)(p+1), tty);
3052-
console_unlock();
30533051
break;
30543052
case TIOCL_PASTESEL:
30553053
ret = paste_selection(tty);

0 commit comments

Comments
 (0)