Skip to content

Commit bbbce51

Browse files
committed
Merge tag 'tty-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are some tty and serial driver fixes for 4.0-rc3. Along with the atime fix that you know about, here are some other serial driver bugfixes as well. Most notable is a wait_until_sent bugfix that was traced back to being around since before 2.6.12 that Johan has fixed up. All have been in linux-next successfully" * tag 'tty-4.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: TTY: fix tty_wait_until_sent maximum timeout TTY: fix tty_wait_until_sent on 64-bit machines USB: serial: fix infinite wait_until_sent timeout TTY: bfin_jtag_comm: remove incorrect wait_until_sent operation net: irda: fix wait_until_sent poll timeout serial: uapi: Declare all userspace-visible io types serial: core: Fix iotype userspace breakage serial: sprd: Fix missing spin_unlock in sprd_handle_irq() console: Fix console name size mismatch tty: fix up atime/mtime mess, take four serial: 8250_dw: Fix get_mctrl behaviour serial:8250:8250_pci: delete unneeded quirk entries serial:8250:8250_pci: fix redundant entry report for WCH_CH352_2S Change email address for 8250_pci serial: 8250: Revert "tty: serial: 8250_core: read only RX if there is something in the FIFO" Revert "tty/serial: of_serial: add DT alias ID handling"
2 parents 47df986 + c37bc68 commit bbbce51

File tree

15 files changed

+89
-61
lines changed

15 files changed

+89
-61
lines changed

Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ Optional properties:
2121
- reg-io-width : the size (in bytes) of the IO accesses that should be
2222
performed on the device. If this property is not present then single byte
2323
accesses are used.
24+
- dcd-override : Override the DCD modem status signal. This signal will always
25+
be reported as active instead of being obtained from the modem status
26+
register. Define this if your serial port does not use this pin.
27+
- dsr-override : Override the DTS modem status signal. This signal will always
28+
be reported as active instead of being obtained from the modem status
29+
register. Define this if your serial port does not use this pin.
30+
- cts-override : Override the CTS modem status signal. This signal will always
31+
be reported as active instead of being obtained from the modem status
32+
register. Define this if your serial port does not use this pin.
33+
- ri-override : Override the RI modem status signal. This signal will always be
34+
reported as inactive instead of being obtained from the modem status register.
35+
Define this if your serial port does not use this pin.
2436

2537
Example:
2638

@@ -31,6 +43,10 @@ Example:
3143
interrupts = <10>;
3244
reg-shift = <2>;
3345
reg-io-width = <4>;
46+
dcd-override;
47+
dsr-override;
48+
cts-override;
49+
ri-override;
3450
};
3551

3652
Example with one clock:

drivers/tty/bfin_jtag_comm.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,6 @@ bfin_jc_chars_in_buffer(struct tty_struct *tty)
210210
return circ_cnt(&bfin_jc_write_buf);
211211
}
212212

213-
static void
214-
bfin_jc_wait_until_sent(struct tty_struct *tty, int timeout)
215-
{
216-
unsigned long expire = jiffies + timeout;
217-
while (!circ_empty(&bfin_jc_write_buf)) {
218-
if (signal_pending(current))
219-
break;
220-
if (time_after(jiffies, expire))
221-
break;
222-
}
223-
}
224-
225213
static const struct tty_operations bfin_jc_ops = {
226214
.open = bfin_jc_open,
227215
.close = bfin_jc_close,
@@ -230,7 +218,6 @@ static const struct tty_operations bfin_jc_ops = {
230218
.flush_chars = bfin_jc_flush_chars,
231219
.write_room = bfin_jc_write_room,
232220
.chars_in_buffer = bfin_jc_chars_in_buffer,
233-
.wait_until_sent = bfin_jc_wait_until_sent,
234221
};
235222

236223
static int __init bfin_jc_init(void)

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,8 +2138,8 @@ int serial8250_do_startup(struct uart_port *port)
21382138
/*
21392139
* Clear the interrupt registers.
21402140
*/
2141-
if (serial_port_in(port, UART_LSR) & UART_LSR_DR)
2142-
serial_port_in(port, UART_RX);
2141+
serial_port_in(port, UART_LSR);
2142+
serial_port_in(port, UART_RX);
21432143
serial_port_in(port, UART_IIR);
21442144
serial_port_in(port, UART_MSR);
21452145

@@ -2300,8 +2300,8 @@ int serial8250_do_startup(struct uart_port *port)
23002300
* saved flags to avoid getting false values from polling
23012301
* routines or the previous session.
23022302
*/
2303-
if (serial_port_in(port, UART_LSR) & UART_LSR_DR)
2304-
serial_port_in(port, UART_RX);
2303+
serial_port_in(port, UART_LSR);
2304+
serial_port_in(port, UART_RX);
23052305
serial_port_in(port, UART_IIR);
23062306
serial_port_in(port, UART_MSR);
23072307
up->lsr_saved_flags = 0;
@@ -2394,8 +2394,7 @@ void serial8250_do_shutdown(struct uart_port *port)
23942394
* Read data port to reset things, and then unlink from
23952395
* the IRQ chain.
23962396
*/
2397-
if (serial_port_in(port, UART_LSR) & UART_LSR_DR)
2398-
serial_port_in(port, UART_RX);
2397+
serial_port_in(port, UART_RX);
23992398
serial8250_rpm_put(up);
24002399

24012400
del_timer_sync(&up->timer);

drivers/tty/serial/8250/8250_dw.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct dw8250_data {
5959
u8 usr_reg;
6060
int last_mcr;
6161
int line;
62+
int msr_mask_on;
63+
int msr_mask_off;
6264
struct clk *clk;
6365
struct clk *pclk;
6466
struct reset_control *rst;
@@ -81,6 +83,12 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
8183
value &= ~UART_MSR_DCTS;
8284
}
8385

86+
/* Override any modem control signals if needed */
87+
if (offset == UART_MSR) {
88+
value |= d->msr_mask_on;
89+
value &= ~d->msr_mask_off;
90+
}
91+
8492
return value;
8593
}
8694

@@ -334,6 +342,30 @@ static int dw8250_probe_of(struct uart_port *p,
334342
if (id >= 0)
335343
p->line = id;
336344

345+
if (of_property_read_bool(np, "dcd-override")) {
346+
/* Always report DCD as active */
347+
data->msr_mask_on |= UART_MSR_DCD;
348+
data->msr_mask_off |= UART_MSR_DDCD;
349+
}
350+
351+
if (of_property_read_bool(np, "dsr-override")) {
352+
/* Always report DSR as active */
353+
data->msr_mask_on |= UART_MSR_DSR;
354+
data->msr_mask_off |= UART_MSR_DDSR;
355+
}
356+
357+
if (of_property_read_bool(np, "cts-override")) {
358+
/* Always report DSR as active */
359+
data->msr_mask_on |= UART_MSR_DSR;
360+
data->msr_mask_off |= UART_MSR_DDSR;
361+
}
362+
363+
if (of_property_read_bool(np, "ri-override")) {
364+
/* Always report Ring indicator as inactive */
365+
data->msr_mask_off |= UART_MSR_RI;
366+
data->msr_mask_off |= UART_MSR_TERI;
367+
}
368+
337369
/* clock got configured through clk api, all done */
338370
if (p->uartclk)
339371
return 0;

drivers/tty/serial/8250/8250_pci.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void moan_device(const char *str, struct pci_dev *dev)
6969
"Please send the output of lspci -vv, this\n"
7070
"message (0x%04x,0x%04x,0x%04x,0x%04x), the\n"
7171
"manufacturer and name of serial board or\n"
72-
"modem board to rmk+serial@arm.linux.org.uk.\n",
72+
"modem board to <linux-serial@vger.kernel.org>.\n",
7373
pci_name(dev), str, dev->vendor, dev->device,
7474
dev->subsystem_vendor, dev->subsystem_device);
7575
}
@@ -1987,13 +1987,6 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
19871987
.subdevice = PCI_ANY_ID,
19881988
.setup = byt_serial_setup,
19891989
},
1990-
{
1991-
.vendor = PCI_VENDOR_ID_INTEL,
1992-
.device = PCI_DEVICE_ID_INTEL_QRK_UART,
1993-
.subvendor = PCI_ANY_ID,
1994-
.subdevice = PCI_ANY_ID,
1995-
.setup = pci_default_setup,
1996-
},
19971990
{
19981991
.vendor = PCI_VENDOR_ID_INTEL,
19991992
.device = PCI_DEVICE_ID_INTEL_BSW_UART1,
@@ -2199,13 +2192,6 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
21992192
/*
22002193
* PLX
22012194
*/
2202-
{
2203-
.vendor = PCI_VENDOR_ID_PLX,
2204-
.device = PCI_DEVICE_ID_PLX_9030,
2205-
.subvendor = PCI_SUBVENDOR_ID_PERLE,
2206-
.subdevice = PCI_ANY_ID,
2207-
.setup = pci_default_setup,
2208-
},
22092195
{
22102196
.vendor = PCI_VENDOR_ID_PLX,
22112197
.device = PCI_DEVICE_ID_PLX_9050,
@@ -5415,10 +5401,6 @@ static struct pci_device_id serial_pci_tbl[] = {
54155401
PCI_ANY_ID, PCI_ANY_ID,
54165402
0, 0, pbn_b0_bt_2_115200 },
54175403

5418-
{ PCI_VENDOR_ID_WCH, PCI_DEVICE_ID_WCH_CH352_2S,
5419-
PCI_ANY_ID, PCI_ANY_ID,
5420-
0, 0, pbn_b0_bt_2_115200 },
5421-
54225404
{ PCIE_VENDOR_ID_WCH, PCIE_DEVICE_ID_WCH_CH384_4S,
54235405
PCI_ANY_ID, PCI_ANY_ID,
54245406
0, 0, pbn_wch384_4 },

drivers/tty/serial/of_serial.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
133133
if (of_find_property(np, "no-loopback-test", NULL))
134134
port->flags |= UPF_SKIP_TEST;
135135

136-
ret = of_alias_get_id(np, "serial");
137-
if (ret >= 0)
138-
port->line = ret;
139-
140136
port->dev = &ofdev->dev;
141137

142138
switch (type) {

drivers/tty/serial/sprd_serial.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,10 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id)
293293

294294
ims = serial_in(port, SPRD_IMSR);
295295

296-
if (!ims)
296+
if (!ims) {
297+
spin_unlock(&port->lock);
297298
return IRQ_NONE;
299+
}
298300

299301
serial_out(port, SPRD_ICLR, ~0);
300302

drivers/tty/tty_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,8 @@ EXPORT_SYMBOL(start_tty);
10281028
/* We limit tty time update visibility to every 8 seconds or so. */
10291029
static void tty_update_time(struct timespec *time)
10301030
{
1031-
unsigned long sec = get_seconds() & ~7;
1032-
if ((long)(sec - time->tv_sec) > 0)
1031+
unsigned long sec = get_seconds();
1032+
if (abs(sec - time->tv_sec) & ~7)
10331033
time->tv_sec = sec;
10341034
}
10351035

drivers/tty/tty_ioctl.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,17 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
217217
#endif
218218
if (!timeout)
219219
timeout = MAX_SCHEDULE_TIMEOUT;
220-
if (wait_event_interruptible_timeout(tty->write_wait,
221-
!tty_chars_in_buffer(tty), timeout) >= 0) {
222-
if (tty->ops->wait_until_sent)
223-
tty->ops->wait_until_sent(tty, timeout);
224-
}
220+
221+
timeout = wait_event_interruptible_timeout(tty->write_wait,
222+
!tty_chars_in_buffer(tty), timeout);
223+
if (timeout <= 0)
224+
return;
225+
226+
if (timeout == MAX_SCHEDULE_TIMEOUT)
227+
timeout = 0;
228+
229+
if (tty->ops->wait_until_sent)
230+
tty->ops->wait_until_sent(tty, timeout);
225231
}
226232
EXPORT_SYMBOL(tty_wait_until_sent);
227233

drivers/usb/serial/generic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout)
258258
* character or at least one jiffy.
259259
*/
260260
period = max_t(unsigned long, (10 * HZ / bps), 1);
261-
period = min_t(unsigned long, period, timeout);
261+
if (timeout)
262+
period = min_t(unsigned long, period, timeout);
262263

263264
dev_dbg(&port->dev, "%s - timeout = %u ms, period = %u ms\n",
264265
__func__, jiffies_to_msecs(timeout),
@@ -268,7 +269,7 @@ void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout)
268269
schedule_timeout_interruptible(period);
269270
if (signal_pending(current))
270271
break;
271-
if (time_after(jiffies, expire))
272+
if (timeout && time_after(jiffies, expire))
272273
break;
273274
}
274275
}

include/linux/serial_core.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ struct uart_port {
143143
unsigned char iotype; /* io access style */
144144
unsigned char unused1;
145145

146-
#define UPIO_PORT (0) /* 8b I/O port access */
147-
#define UPIO_HUB6 (1) /* Hub6 ISA card */
148-
#define UPIO_MEM (2) /* 8b MMIO access */
149-
#define UPIO_MEM32 (3) /* 32b little endian */
150-
#define UPIO_MEM32BE (4) /* 32b big endian */
151-
#define UPIO_AU (5) /* Au1x00 and RT288x type IO */
152-
#define UPIO_TSI (6) /* Tsi108/109 type IO */
146+
#define UPIO_PORT (SERIAL_IO_PORT) /* 8b I/O port access */
147+
#define UPIO_HUB6 (SERIAL_IO_HUB6) /* Hub6 ISA card */
148+
#define UPIO_MEM (SERIAL_IO_MEM) /* 8b MMIO access */
149+
#define UPIO_MEM32 (SERIAL_IO_MEM32) /* 32b little endian */
150+
#define UPIO_AU (SERIAL_IO_AU) /* Au1x00 and RT288x type IO */
151+
#define UPIO_TSI (SERIAL_IO_TSI) /* Tsi108/109 type IO */
152+
#define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */
153153

154154
unsigned int read_status_mask; /* driver specific */
155155
unsigned int ignore_status_mask; /* driver specific */

include/uapi/linux/serial.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ struct serial_struct {
6565
#define SERIAL_IO_PORT 0
6666
#define SERIAL_IO_HUB6 1
6767
#define SERIAL_IO_MEM 2
68+
#define SERIAL_IO_MEM32 3
69+
#define SERIAL_IO_AU 4
70+
#define SERIAL_IO_TSI 5
71+
#define SERIAL_IO_MEM32BE 6
6872

6973
#define UART_CLEAR_FIFO 0x01
7074
#define UART_USE_FIFO 0x02

kernel/printk/console_cmdline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
struct console_cmdline
55
{
6-
char name[8]; /* Name of the driver */
6+
char name[16]; /* Name of the driver */
77
int index; /* Minor dev. to use */
88
char *options; /* Options for the driver */
99
#ifdef CONFIG_A11Y_BRAILLE_CONSOLE

kernel/printk/printk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,6 +2464,7 @@ void register_console(struct console *newcon)
24642464
for (i = 0, c = console_cmdline;
24652465
i < MAX_CMDLINECONSOLES && c->name[0];
24662466
i++, c++) {
2467+
BUILD_BUG_ON(sizeof(c->name) != sizeof(newcon->name));
24672468
if (strcmp(c->name, newcon->name) != 0)
24682469
continue;
24692470
if (newcon->index >= 0 &&

net/irda/ircomm/ircomm_tty.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,9 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
798798
orig_jiffies = jiffies;
799799

800800
/* Set poll time to 200 ms */
801-
poll_time = IRDA_MIN(timeout, msecs_to_jiffies(200));
801+
poll_time = msecs_to_jiffies(200);
802+
if (timeout)
803+
poll_time = min_t(unsigned long, timeout, poll_time);
802804

803805
spin_lock_irqsave(&self->spinlock, flags);
804806
while (self->tx_skb && self->tx_skb->len) {

0 commit comments

Comments
 (0)