Skip to content

Commit 5bd4af3

Browse files
committed
Merge tag 'tty-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial updates from Greg KH: "Here is the big tty and serial pull request for 4.20-rc1 Lots of little things here, including a merge from the SPI tree in order to keep things simpler for everyone to sync around for one platform. Major stuff is: - tty buffer clearing after use - atmel_serial fixes and additions - xilinx uart driver updates and of course, lots of tiny fixes and additions to individual serial drivers. All of these have been in linux-next with no reported issues for a while" * tag 'tty-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (66 commits) of: base: Change logic in of_alias_get_alias_list() of: base: Fix english spelling in of_alias_get_alias_list() serial: sh-sci: do not warn if DMA transfers are not supported serial: uartps: Do not allow use aliases >= MAX_UART_INSTANCES tty: check name length in tty_find_polling_driver() serial: sh-sci: Add r8a77990 support tty: wipe buffer if not echoing data tty: wipe buffer. serial: fsl_lpuart: Remove the alias node dependence TTY: sn_console: Replace spin_is_locked() with spin_trylock() Revert "serial:serial_core: Allow use of CTS for PPS line discipline" serial: 8250_uniphier: add auto-flow-control support serial: 8250_uniphier: flatten probe function serial: 8250_uniphier: remove unused "fifo-size" property dt-bindings: serial: sh-sci: Document r8a7744 bindings serial: uartps: Fix missing unlock on error in cdns_get_id() tty/serial: atmel: add ISO7816 support tty/serial_core: add ISO7816 infrastructure serial:serial_core: Allow use of CTS for PPS line discipline serial: docs: Fix filename for serial reference implementation ...
2 parents 738b04f + 59eaeba commit 5bd4af3

File tree

43 files changed

+977
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+977
-380
lines changed

Documentation/devicetree/bindings/serial/renesas,sci-serial.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Required properties:
1414
- "renesas,scifa-r8a7743" for R8A7743 (RZ/G1M) SCIFA compatible UART.
1515
- "renesas,scifb-r8a7743" for R8A7743 (RZ/G1M) SCIFB compatible UART.
1616
- "renesas,hscif-r8a7743" for R8A7743 (RZ/G1M) HSCIF compatible UART.
17+
- "renesas,scif-r8a7744" for R8A7744 (RZ/G1N) SCIF compatible UART.
18+
- "renesas,scifa-r8a7744" for R8A7744 (RZ/G1N) SCIFA compatible UART.
19+
- "renesas,scifb-r8a7744" for R8A7744 (RZ/G1N) SCIFB compatible UART.
20+
- "renesas,hscif-r8a7744" for R8A7744 (RZ/G1N) HSCIF compatible UART.
1721
- "renesas,scif-r8a7745" for R8A7745 (RZ/G1E) SCIF compatible UART.
1822
- "renesas,scifa-r8a7745" for R8A7745 (RZ/G1E) SCIFA compatible UART.
1923
- "renesas,scifb-r8a7745" for R8A7745 (RZ/G1E) SCIFB compatible UART.
@@ -50,6 +54,8 @@ Required properties:
5054
- "renesas,hscif-r8a77970" for R8A77970 (R-Car V3M) HSCIF compatible UART.
5155
- "renesas,scif-r8a77980" for R8A77980 (R-Car V3H) SCIF compatible UART.
5256
- "renesas,hscif-r8a77980" for R8A77980 (R-Car V3H) HSCIF compatible UART.
57+
- "renesas,scif-r8a77990" for R8A77990 (R-Car E3) SCIF compatible UART.
58+
- "renesas,hscif-r8a77990" for R8A77990 (R-Car E3) HSCIF compatible UART.
5359
- "renesas,scif-r8a77995" for R8A77995 (R-Car D3) SCIF compatible UART.
5460
- "renesas,hscif-r8a77995" for R8A77995 (R-Car D3) HSCIF compatible UART.
5561
- "renesas,scifa-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFA compatible UART.

Documentation/devicetree/bindings/serial/uniphier-uart.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Required properties:
77
- clocks: phandle to the input clock.
88

99
Optional properties:
10-
- fifo-size: the RX/TX FIFO size. Defaults to 64 if not specified.
10+
-auto-flow-control: enable automatic flow control support.
1111

1212
Example:
1313
aliases {
@@ -19,5 +19,4 @@ Example:
1919
reg = <0x54006800 0x40>;
2020
interrupts = <0 33 4>;
2121
clocks = <&uart_clk>;
22-
fifo-size = <64>;
2322
};

Documentation/serial/driver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This document is meant as a brief overview of some aspects of the new serial
77
driver. It is not complete, any questions you have should be directed to
88
<rmk@arm.linux.org.uk>
99

10-
The reference implementation is contained within amba_pl011.c.
10+
The reference implementation is contained within amba-pl011.c.
1111

1212

1313

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
ISO7816 SERIAL COMMUNICATIONS
2+
3+
1. INTRODUCTION
4+
5+
ISO/IEC7816 is a series of standards specifying integrated circuit cards (ICC)
6+
also known as smart cards.
7+
8+
2. HARDWARE-RELATED CONSIDERATIONS
9+
10+
Some CPUs/UARTs (e.g., Microchip AT91) contain a built-in mode capable of
11+
handling communication with a smart card.
12+
13+
For these microcontrollers, the Linux driver should be made capable of
14+
working in both modes, and proper ioctls (see later) should be made
15+
available at user-level to allow switching from one mode to the other, and
16+
vice versa.
17+
18+
3. DATA STRUCTURES ALREADY AVAILABLE IN THE KERNEL
19+
20+
The Linux kernel provides the serial_iso7816 structure (see [1]) to handle
21+
ISO7816 communications. This data structure is used to set and configure
22+
ISO7816 parameters in ioctls.
23+
24+
Any driver for devices capable of working both as RS232 and ISO7816 should
25+
implement the iso7816_config callback in the uart_port structure. The
26+
serial_core calls iso7816_config to do the device specific part in response
27+
to TIOCGISO7816 and TIOCSISO7816 ioctls (see below). The iso7816_config
28+
callback receives a pointer to struct serial_iso7816.
29+
30+
4. USAGE FROM USER-LEVEL
31+
32+
From user-level, ISO7816 configuration can be get/set using the previous
33+
ioctls. For instance, to set ISO7816 you can use the following code:
34+
35+
#include <linux/serial.h>
36+
37+
/* Include definition for ISO7816 ioctls: TIOCSISO7816 and TIOCGISO7816 */
38+
#include <sys/ioctl.h>
39+
40+
/* Open your specific device (e.g., /dev/mydevice): */
41+
int fd = open ("/dev/mydevice", O_RDWR);
42+
if (fd < 0) {
43+
/* Error handling. See errno. */
44+
}
45+
46+
struct serial_iso7816 iso7816conf;
47+
48+
/* Reserved fields as to be zeroed */
49+
memset(&iso7816conf, 0, sizeof(iso7816conf));
50+
51+
/* Enable ISO7816 mode: */
52+
iso7816conf.flags |= SER_ISO7816_ENABLED;
53+
54+
/* Select the protocol: */
55+
/* T=0 */
56+
iso7816conf.flags |= SER_ISO7816_T(0);
57+
/* or T=1 */
58+
iso7816conf.flags |= SER_ISO7816_T(1);
59+
60+
/* Set the guard time: */
61+
iso7816conf.tg = 2;
62+
63+
/* Set the clock frequency*/
64+
iso7816conf.clk = 3571200;
65+
66+
/* Set transmission factors: */
67+
iso7816conf.sc_fi = 372;
68+
iso7816conf.sc_di = 1;
69+
70+
if (ioctl(fd_usart, TIOCSISO7816, &iso7816conf) < 0) {
71+
/* Error handling. See errno. */
72+
}
73+
74+
/* Use read() and write() syscalls here... */
75+
76+
/* Close the device when finished: */
77+
if (close (fd) < 0) {
78+
/* Error handling. See errno. */
79+
}
80+
81+
5. REFERENCES
82+
83+
[1] include/uapi/linux/serial.h

arch/alpha/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
103103
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
104104
#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
105+
#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
106+
#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
105107

106108
#define TIOCSERCONFIG 0x5453
107109
#define TIOCSERGWILD 0x5454

arch/mips/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
9494
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
9595
#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
96+
#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
97+
#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
9698

9799
/* I hope the range from 0x5480 on is free ... */
98100
#define TIOCSCTTY 0x5480 /* become controlling tty */

arch/parisc/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
6363
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
6464
#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
65+
#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
66+
#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
6567

6668
#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
6769
#define FIOCLEX 0x5451

arch/powerpc/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@
102102
#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
103103
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
104104
#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
105+
#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
106+
#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
105107

106108
#define TIOCSERCONFIG 0x5453
107109
#define TIOCSERGWILD 0x5454

arch/sh/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
9696
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
9797
#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
98+
#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
99+
#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
98100

99101
#define TIOCSERCONFIG _IO('T', 83) /* 0x5453 */
100102
#define TIOCSERGWILD _IOR('T', 84, int) /* 0x5454 */

arch/sparc/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
2828
#define TIOCGRS485 _IOR('T', 0x41, struct serial_rs485)
2929
#define TIOCSRS485 _IOWR('T', 0x42, struct serial_rs485)
30+
#define TIOCGISO7816 _IOR('T', 0x43, struct serial_iso7816)
31+
#define TIOCSISO7816 _IOWR('T', 0x44, struct serial_iso7816)
3032

3133
/* Note that all the ioctls that are not available in Linux have a
3234
* double underscore on the front to: a) avoid some programs to

arch/xtensa/include/uapi/asm/ioctls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
108108
#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
109109
#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
110+
#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
111+
#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
110112

111113
#define TIOCSERCONFIG _IO('T', 83)
112114
#define TIOCSERGWILD _IOR('T', 84, int)

drivers/of/base.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#define pr_fmt(fmt) "OF: " fmt
1818

19+
#include <linux/bitmap.h>
1920
#include <linux/console.h>
2021
#include <linux/ctype.h>
2122
#include <linux/cpu.h>
@@ -1985,6 +1986,59 @@ int of_alias_get_id(struct device_node *np, const char *stem)
19851986
}
19861987
EXPORT_SYMBOL_GPL(of_alias_get_id);
19871988

1989+
/**
1990+
* of_alias_get_alias_list - Get alias list for the given device driver
1991+
* @matches: Array of OF device match structures to search in
1992+
* @stem: Alias stem of the given device_node
1993+
* @bitmap: Bitmap field pointer
1994+
* @nbits: Maximum number of alias IDs which can be recorded in bitmap
1995+
*
1996+
* The function travels the lookup table to record alias ids for the given
1997+
* device match structures and alias stem.
1998+
*
1999+
* Return: 0 or -ENOSYS when !CONFIG_OF or
2000+
* -EOVERFLOW if alias ID is greater then allocated nbits
2001+
*/
2002+
int of_alias_get_alias_list(const struct of_device_id *matches,
2003+
const char *stem, unsigned long *bitmap,
2004+
unsigned int nbits)
2005+
{
2006+
struct alias_prop *app;
2007+
int ret = 0;
2008+
2009+
/* Zero bitmap field to make sure that all the time it is clean */
2010+
bitmap_zero(bitmap, nbits);
2011+
2012+
mutex_lock(&of_mutex);
2013+
pr_debug("%s: Looking for stem: %s\n", __func__, stem);
2014+
list_for_each_entry(app, &aliases_lookup, link) {
2015+
pr_debug("%s: stem: %s, id: %d\n",
2016+
__func__, app->stem, app->id);
2017+
2018+
if (strcmp(app->stem, stem) != 0) {
2019+
pr_debug("%s: stem comparison didn't pass %s\n",
2020+
__func__, app->stem);
2021+
continue;
2022+
}
2023+
2024+
if (of_match_node(matches, app->np)) {
2025+
pr_debug("%s: Allocated ID %d\n", __func__, app->id);
2026+
2027+
if (app->id >= nbits) {
2028+
pr_warn("%s: ID %d >= than bitmap field %d\n",
2029+
__func__, app->id, nbits);
2030+
ret = -EOVERFLOW;
2031+
} else {
2032+
set_bit(app->id, bitmap);
2033+
}
2034+
}
2035+
}
2036+
mutex_unlock(&of_mutex);
2037+
2038+
return ret;
2039+
}
2040+
EXPORT_SYMBOL_GPL(of_alias_get_alias_list);
2041+
19882042
/**
19892043
* of_alias_get_highest_id - Get highest alias id for the given stem
19902044
* @stem: Alias stem to be examined

drivers/tty/ehv_bytechan.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ static int find_console_handle(void)
128128
*/
129129
iprop = of_get_property(np, "hv-handle", NULL);
130130
if (!iprop) {
131-
pr_err("ehv-bc: no 'hv-handle' property in %s node\n",
132-
np->name);
131+
pr_err("ehv-bc: no 'hv-handle' property in %pOFn node\n",
132+
np);
133133
return 0;
134134
}
135135
stdout_bc = be32_to_cpu(*iprop);
@@ -661,8 +661,8 @@ static int ehv_bc_tty_probe(struct platform_device *pdev)
661661

662662
iprop = of_get_property(np, "hv-handle", NULL);
663663
if (!iprop) {
664-
dev_err(&pdev->dev, "no 'hv-handle' property in %s node\n",
665-
np->name);
664+
dev_err(&pdev->dev, "no 'hv-handle' property in %pOFn node\n",
665+
np);
666666
return -ENODEV;
667667
}
668668

@@ -682,8 +682,8 @@ static int ehv_bc_tty_probe(struct platform_device *pdev)
682682
bc->rx_irq = irq_of_parse_and_map(np, 0);
683683
bc->tx_irq = irq_of_parse_and_map(np, 1);
684684
if ((bc->rx_irq == NO_IRQ) || (bc->tx_irq == NO_IRQ)) {
685-
dev_err(&pdev->dev, "no 'interrupts' property in %s node\n",
686-
np->name);
685+
dev_err(&pdev->dev, "no 'interrupts' property in %pOFn node\n",
686+
np);
687687
ret = -ENODEV;
688688
goto error;
689689
}

drivers/tty/n_tty.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,28 @@ static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i)
152152
return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)];
153153
}
154154

155+
/* If we are not echoing the data, perhaps this is a secret so erase it */
156+
static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size)
157+
{
158+
bool icanon = !!L_ICANON(tty);
159+
bool no_echo = !L_ECHO(tty);
160+
161+
if (icanon && no_echo)
162+
memset(buffer, 0x00, size);
163+
}
164+
155165
static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
156166
size_t tail, size_t n)
157167
{
158168
struct n_tty_data *ldata = tty->disc_data;
159169
size_t size = N_TTY_BUF_SIZE - tail;
160-
const void *from = read_buf_addr(ldata, tail);
170+
void *from = read_buf_addr(ldata, tail);
161171
int uncopied;
162172

163173
if (n > size) {
164174
tty_audit_add_data(tty, from, size);
165175
uncopied = copy_to_user(to, from, size);
176+
zero_buffer(tty, from, size - uncopied);
166177
if (uncopied)
167178
return uncopied;
168179
to += size;
@@ -171,7 +182,9 @@ static int tty_copy_to_user(struct tty_struct *tty, void __user *to,
171182
}
172183

173184
tty_audit_add_data(tty, from, n);
174-
return copy_to_user(to, from, n);
185+
uncopied = copy_to_user(to, from, n);
186+
zero_buffer(tty, from, n - uncopied);
187+
return uncopied;
175188
}
176189

177190
/**
@@ -1960,11 +1973,12 @@ static int copy_from_read_buf(struct tty_struct *tty,
19601973
n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail);
19611974
n = min(*nr, n);
19621975
if (n) {
1963-
const unsigned char *from = read_buf_addr(ldata, tail);
1976+
unsigned char *from = read_buf_addr(ldata, tail);
19641977
retval = copy_to_user(*b, from, n);
19651978
n -= retval;
19661979
is_eof = n == 1 && *from == EOF_CHAR(tty);
19671980
tty_audit_add_data(tty, from, n);
1981+
zero_buffer(tty, from, n);
19681982
smp_store_release(&ldata->read_tail, ldata->read_tail + n);
19691983
/* Turn single EOF into zero-length read */
19701984
if (L_EXTPROC(tty) && ldata->icanon && is_eof &&

drivers/tty/serial/8250/8250_core.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,8 @@ static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
130130

131131
l = l->next;
132132

133-
if (l == i->head && pass_counter++ > PASS_LIMIT) {
134-
/* If we hit this, we're dead. */
135-
printk_ratelimited(KERN_ERR
136-
"serial8250: too much work for irq%d\n", irq);
133+
if (l == i->head && pass_counter++ > PASS_LIMIT)
137134
break;
138-
}
139135
} while (l != end);
140136

141137
spin_unlock(&i->lock);

0 commit comments

Comments
 (0)