Skip to content

Commit 3f667b5

Browse files
committed
Merge tag 'tty-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial fixes from Greg KH: "Here are two small tty/serial fixes for 5.16-rc6. They include: - n_hdlc fix for syzbot reported problem that you were previously copied on. - 8250_fintek driver fix that resolved a console problem by removing a previous change. Both have been in linux-next with no reported issues" * tag 'tty-5.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: serial: 8250_fintek: Fix garbled text for console tty: n_hdlc: make n_hdlc_tty_wakeup() asynchronous
2 parents fb7d082 + 6c33ff7 commit 3f667b5

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

drivers/tty/n_hdlc.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ struct n_hdlc {
140140
struct n_hdlc_buf_list rx_buf_list;
141141
struct n_hdlc_buf_list tx_free_buf_list;
142142
struct n_hdlc_buf_list rx_free_buf_list;
143+
struct work_struct write_work;
144+
struct tty_struct *tty_for_write_work;
143145
};
144146

145147
/*
@@ -154,6 +156,7 @@ static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *list);
154156
/* Local functions */
155157

156158
static struct n_hdlc *n_hdlc_alloc(void);
159+
static void n_hdlc_tty_write_work(struct work_struct *work);
157160

158161
/* max frame size for memory allocations */
159162
static int maxframe = 4096;
@@ -210,6 +213,8 @@ static void n_hdlc_tty_close(struct tty_struct *tty)
210213
wake_up_interruptible(&tty->read_wait);
211214
wake_up_interruptible(&tty->write_wait);
212215

216+
cancel_work_sync(&n_hdlc->write_work);
217+
213218
n_hdlc_free_buf_list(&n_hdlc->rx_free_buf_list);
214219
n_hdlc_free_buf_list(&n_hdlc->tx_free_buf_list);
215220
n_hdlc_free_buf_list(&n_hdlc->rx_buf_list);
@@ -241,6 +246,8 @@ static int n_hdlc_tty_open(struct tty_struct *tty)
241246
return -ENFILE;
242247
}
243248

249+
INIT_WORK(&n_hdlc->write_work, n_hdlc_tty_write_work);
250+
n_hdlc->tty_for_write_work = tty;
244251
tty->disc_data = n_hdlc;
245252
tty->receive_room = 65536;
246253

@@ -334,6 +341,20 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
334341
goto check_again;
335342
} /* end of n_hdlc_send_frames() */
336343

344+
/**
345+
* n_hdlc_tty_write_work - Asynchronous callback for transmit wakeup
346+
* @work: pointer to work_struct
347+
*
348+
* Called when low level device driver can accept more send data.
349+
*/
350+
static void n_hdlc_tty_write_work(struct work_struct *work)
351+
{
352+
struct n_hdlc *n_hdlc = container_of(work, struct n_hdlc, write_work);
353+
struct tty_struct *tty = n_hdlc->tty_for_write_work;
354+
355+
n_hdlc_send_frames(n_hdlc, tty);
356+
} /* end of n_hdlc_tty_write_work() */
357+
337358
/**
338359
* n_hdlc_tty_wakeup - Callback for transmit wakeup
339360
* @tty: pointer to associated tty instance data
@@ -344,7 +365,7 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
344365
{
345366
struct n_hdlc *n_hdlc = tty->disc_data;
346367

347-
n_hdlc_send_frames(n_hdlc, tty);
368+
schedule_work(&n_hdlc->write_work);
348369
} /* end of n_hdlc_tty_wakeup() */
349370

350371
/**

drivers/tty/serial/8250/8250_fintek.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,6 @@ static void fintek_8250_set_max_fifo(struct fintek_8250 *pdata)
290290
}
291291
}
292292

293-
static void fintek_8250_goto_highspeed(struct uart_8250_port *uart,
294-
struct fintek_8250 *pdata)
295-
{
296-
sio_write_reg(pdata, LDN, pdata->index);
297-
298-
switch (pdata->pid) {
299-
case CHIP_ID_F81966:
300-
case CHIP_ID_F81866: /* set uart clock for high speed serial mode */
301-
sio_write_mask_reg(pdata, F81866_UART_CLK,
302-
F81866_UART_CLK_MASK,
303-
F81866_UART_CLK_14_769MHZ);
304-
305-
uart->port.uartclk = 921600 * 16;
306-
break;
307-
default: /* leave clock speed untouched */
308-
break;
309-
}
310-
}
311-
312293
static void fintek_8250_set_termios(struct uart_port *port,
313294
struct ktermios *termios,
314295
struct ktermios *old)
@@ -430,7 +411,6 @@ static int probe_setup_port(struct fintek_8250 *pdata,
430411

431412
fintek_8250_set_irq_mode(pdata, level_mode);
432413
fintek_8250_set_max_fifo(pdata);
433-
fintek_8250_goto_highspeed(uart, pdata);
434414

435415
fintek_8250_exit_key(addr[i]);
436416

0 commit comments

Comments
 (0)