File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -545,6 +545,12 @@ int tty_set_ldisc(struct tty_struct *tty, int disc)
545
545
goto out ;
546
546
}
547
547
548
+ if (tty -> ops -> ldisc_ok ) {
549
+ retval = tty -> ops -> ldisc_ok (tty , disc );
550
+ if (retval )
551
+ goto out ;
552
+ }
553
+
548
554
old_ldisc = tty -> ldisc ;
549
555
550
556
/* Shutdown the old discipline. */
Original file line number Diff line number Diff line change @@ -3576,6 +3576,15 @@ static void con_cleanup(struct tty_struct *tty)
3576
3576
tty_port_put (& vc -> port );
3577
3577
}
3578
3578
3579
+ /*
3580
+ * We can't deal with anything but the N_TTY ldisc,
3581
+ * because we can sleep in our write() routine.
3582
+ */
3583
+ static int con_ldisc_ok (struct tty_struct * tty , int ldisc )
3584
+ {
3585
+ return ldisc == N_TTY ? 0 : - EINVAL ;
3586
+ }
3587
+
3579
3588
static int default_color = 7 ; /* white */
3580
3589
static int default_italic_color = 2 ; // green (ASCII)
3581
3590
static int default_underline_color = 3 ; // cyan (ASCII)
@@ -3695,6 +3704,7 @@ static const struct tty_operations con_ops = {
3695
3704
.resize = vt_resize ,
3696
3705
.shutdown = con_shutdown ,
3697
3706
.cleanup = con_cleanup ,
3707
+ .ldisc_ok = con_ldisc_ok ,
3698
3708
};
3699
3709
3700
3710
static struct cdev vc0_cdev ;
Original file line number Diff line number Diff line change @@ -154,6 +154,13 @@ struct serial_struct;
154
154
*
155
155
* Optional. Called under the @tty->termios_rwsem. May sleep.
156
156
*
157
+ * @ldisc_ok: ``int ()(struct tty_struct *tty, int ldisc)``
158
+ *
159
+ * This routine allows the @tty driver to decide if it can deal
160
+ * with a particular @ldisc.
161
+ *
162
+ * Optional. Called under the @tty->ldisc_sem and @tty->termios_rwsem.
163
+ *
157
164
* @set_ldisc: ``void ()(struct tty_struct *tty)``
158
165
*
159
166
* This routine allows the @tty driver to be notified when the device's
@@ -372,6 +379,7 @@ struct tty_operations {
372
379
void (* hangup )(struct tty_struct * tty );
373
380
int (* break_ctl )(struct tty_struct * tty , int state );
374
381
void (* flush_buffer )(struct tty_struct * tty );
382
+ int (* ldisc_ok )(struct tty_struct * tty , int ldisc );
375
383
void (* set_ldisc )(struct tty_struct * tty );
376
384
void (* wait_until_sent )(struct tty_struct * tty , int timeout );
377
385
void (* send_xchar )(struct tty_struct * tty , u8 ch );
You can’t perform that action at this time.
0 commit comments