Skip to content

Commit cc14086

Browse files
committed
Merge tag 'tty-5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are some small tty and serial driver fixes to resolve some reported problems: - led tty trigger fixes based on review and were acked by the led maintainer - revert a max310x serial driver patch as it was causing problems - revert a pty change as it was also causing problems All of these have been in linux-next for a while with no reported problems" * tag 'tty-5.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: Revert "drivers:tty:pty: Fix a race causing data loss on close" Revert "serial: max310x: rework RX interrupt handling" leds: trigger/tty: Use led_set_brightness_sync() from workqueue leds: trigger: Fix error path to not unlock the unlocked mutex
2 parents 5c7bdbf + c776b77 commit cc14086

File tree

4 files changed

+13
-47
lines changed

4 files changed

+13
-47
lines changed

drivers/leds/trigger/ledtrig-tty.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ static ssize_t ttyname_store(struct device *dev,
5151

5252
if (size) {
5353
ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
54-
if (!ttyname) {
55-
ret = -ENOMEM;
56-
goto out_unlock;
57-
}
54+
if (!ttyname)
55+
return -ENOMEM;
5856
} else {
5957
ttyname = NULL;
6058
}
@@ -69,7 +67,6 @@ static ssize_t ttyname_store(struct device *dev,
6967

7068
trigger_data->ttyname = ttyname;
7169

72-
out_unlock:
7370
mutex_unlock(&trigger_data->mutex);
7471

7572
if (ttyname && !running)
@@ -125,12 +122,12 @@ static void ledtrig_tty_work(struct work_struct *work)
125122

126123
if (icount.rx != trigger_data->rx ||
127124
icount.tx != trigger_data->tx) {
128-
led_set_brightness(trigger_data->led_cdev, LED_ON);
125+
led_set_brightness_sync(trigger_data->led_cdev, LED_ON);
129126

130127
trigger_data->rx = icount.rx;
131128
trigger_data->tx = icount.tx;
132129
} else {
133-
led_set_brightness(trigger_data->led_cdev, LED_OFF);
130+
led_set_brightness_sync(trigger_data->led_cdev, LED_OFF);
134131
}
135132

136133
out:

drivers/tty/pty.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
6666
wake_up_interruptible(&tty->link->read_wait);
6767
wake_up_interruptible(&tty->link->write_wait);
6868
if (tty->driver->subtype == PTY_TYPE_MASTER) {
69-
struct file *f;
70-
69+
set_bit(TTY_OTHER_CLOSED, &tty->flags);
7170
#ifdef CONFIG_UNIX98_PTYS
7271
if (tty->driver == ptm_driver) {
7372
mutex_lock(&devpts_mutex);
@@ -76,17 +75,7 @@ static void pty_close(struct tty_struct *tty, struct file *filp)
7675
mutex_unlock(&devpts_mutex);
7776
}
7877
#endif
79-
80-
/*
81-
* This hack is required because a program can open a
82-
* pty and redirect a console to it, but if the pty is
83-
* closed and the console is not released, then the
84-
* slave side will never close. So release the
85-
* redirect when the master closes.
86-
*/
87-
f = tty_release_redirect(tty->link);
88-
if (f)
89-
fput(f);
78+
tty_vhangup(tty->link);
9079
}
9180
}
9281

drivers/tty/serial/max310x.c

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,9 @@ static int max310x_startup(struct uart_port *port)
10561056
max310x_port_update(port, MAX310X_MODE1_REG,
10571057
MAX310X_MODE1_TRNSCVCTRL_BIT, 0);
10581058

1059-
/* Reset FIFOs */
1060-
max310x_port_write(port, MAX310X_MODE2_REG,
1061-
MAX310X_MODE2_FIFORST_BIT);
1059+
/* Configure MODE2 register & Reset FIFOs*/
1060+
val = MAX310X_MODE2_RXEMPTINV_BIT | MAX310X_MODE2_FIFORST_BIT;
1061+
max310x_port_write(port, MAX310X_MODE2_REG, val);
10621062
max310x_port_update(port, MAX310X_MODE2_REG,
10631063
MAX310X_MODE2_FIFORST_BIT, 0);
10641064

@@ -1086,27 +1086,8 @@ static int max310x_startup(struct uart_port *port)
10861086
/* Clear IRQ status register */
10871087
max310x_port_read(port, MAX310X_IRQSTS_REG);
10881088

1089-
/*
1090-
* Let's ask for an interrupt after a timeout equivalent to
1091-
* the receiving time of 4 characters after the last character
1092-
* has been received.
1093-
*/
1094-
max310x_port_write(port, MAX310X_RXTO_REG, 4);
1095-
1096-
/*
1097-
* Make sure we also get RX interrupts when the RX FIFO is
1098-
* filling up quickly, so get an interrupt when half of the RX
1099-
* FIFO has been filled in.
1100-
*/
1101-
max310x_port_write(port, MAX310X_FIFOTRIGLVL_REG,
1102-
MAX310X_FIFOTRIGLVL_RX(MAX310X_FIFO_SIZE / 2));
1103-
1104-
/* Enable RX timeout interrupt in LSR */
1105-
max310x_port_write(port, MAX310X_LSR_IRQEN_REG,
1106-
MAX310X_LSR_RXTO_BIT);
1107-
1108-
/* Enable LSR, RX FIFO trigger, CTS change interrupts */
1109-
val = MAX310X_IRQ_LSR_BIT | MAX310X_IRQ_RXFIFO_BIT | MAX310X_IRQ_TXEMPTY_BIT;
1089+
/* Enable RX, TX, CTS change interrupts */
1090+
val = MAX310X_IRQ_RXEMPTY_BIT | MAX310X_IRQ_TXEMPTY_BIT;
11101091
max310x_port_write(port, MAX310X_IRQEN_REG, val | MAX310X_IRQ_CTS_BIT);
11111092

11121093
return 0;

drivers/tty/tty_io.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,7 @@ EXPORT_SYMBOL_GPL(tty_wakeup);
544544
* @tty: tty device
545545
*
546546
* This is available to the pty code so if the master closes, if the
547-
* slave is a redirect it can release the redirect. It returns the
548-
* filp for the redirect, which must be fput when the operations on
549-
* the tty are completed.
547+
* slave is a redirect it can release the redirect.
550548
*/
551549
struct file *tty_release_redirect(struct tty_struct *tty)
552550
{
@@ -561,6 +559,7 @@ struct file *tty_release_redirect(struct tty_struct *tty)
561559

562560
return f;
563561
}
562+
EXPORT_SYMBOL_GPL(tty_release_redirect);
564563

565564
/**
566565
* __tty_hangup - actual handler for hangup events

0 commit comments

Comments
 (0)