tty_ioctl.c (2a906db2824b75444982f5e9df870106982afca8) | tty_ioctl.c (1d5d66825610bb7be23e2229731261c8e99eaa28) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 4 * 5 * Modified by Fred N. van Kempen, 01/29/93, to add line disciplines 6 * which can be dynamically activated and de-activated by the line 7 * discipline handling modules (like SLIP). 8 */ --- 205 unchanged lines hidden (view full) --- 214} 215EXPORT_SYMBOL(tty_wait_until_sent); 216 217 218/* 219 * Termios Helper Methods 220 */ 221 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 4 * 5 * Modified by Fred N. van Kempen, 01/29/93, to add line disciplines 6 * which can be dynamically activated and de-activated by the line 7 * discipline handling modules (like SLIP). 8 */ --- 205 unchanged lines hidden (view full) --- 214} 215EXPORT_SYMBOL(tty_wait_until_sent); 216 217 218/* 219 * Termios Helper Methods 220 */ 221 |
222static void unset_locked_termios(struct tty_struct *tty, struct ktermios *old) | 222static void unset_locked_termios(struct tty_struct *tty, const struct ktermios *old) |
223{ 224 struct ktermios *termios = &tty->termios; 225 struct ktermios *locked = &tty->termios_locked; 226 int i; 227 228#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z))) 229 230 NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag); --- 13 unchanged lines hidden (view full) --- 244 * @old: Old termios 245 * 246 * Propagate the hardware specific terminal setting bits from 247 * the old termios structure to the new one. This is used in cases 248 * where the hardware does not support reconfiguration or as a helper 249 * in some cases where only minimal reconfiguration is supported 250 */ 251 | 223{ 224 struct ktermios *termios = &tty->termios; 225 struct ktermios *locked = &tty->termios_locked; 226 int i; 227 228#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z))) 229 230 NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag); --- 13 unchanged lines hidden (view full) --- 244 * @old: Old termios 245 * 246 * Propagate the hardware specific terminal setting bits from 247 * the old termios structure to the new one. This is used in cases 248 * where the hardware does not support reconfiguration or as a helper 249 * in some cases where only minimal reconfiguration is supported 250 */ 251 |
252void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old) | 252void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old) |
253{ 254 /* The bits a dumb device handles in software. Smart devices need 255 to always provide a set_termios method */ 256 new->c_cflag &= HUPCL | CREAD | CLOCAL; 257 new->c_cflag |= old->c_cflag & ~(HUPCL | CREAD | CLOCAL); 258 new->c_ispeed = old->c_ispeed; 259 new->c_ospeed = old->c_ospeed; 260} --- 108 unchanged lines hidden (view full) --- 369 ld->ops->set_termios(tty, &old_termios); 370 tty_ldisc_deref(ld); 371 } 372 up_write(&tty->termios_rwsem); 373 return 0; 374} 375EXPORT_SYMBOL_GPL(tty_set_termios); 376 | 253{ 254 /* The bits a dumb device handles in software. Smart devices need 255 to always provide a set_termios method */ 256 new->c_cflag &= HUPCL | CREAD | CLOCAL; 257 new->c_cflag |= old->c_cflag & ~(HUPCL | CREAD | CLOCAL); 258 new->c_ispeed = old->c_ispeed; 259 new->c_ospeed = old->c_ospeed; 260} --- 108 unchanged lines hidden (view full) --- 369 ld->ops->set_termios(tty, &old_termios); 370 tty_ldisc_deref(ld); 371 } 372 up_write(&tty->termios_rwsem); 373 return 0; 374} 375EXPORT_SYMBOL_GPL(tty_set_termios); 376 |
377 378/* 379 * Translate a "termio" structure into a "termios". Ugh. 380 */ 381__weak int user_termio_to_kernel_termios(struct ktermios *termios, 382 struct termio __user *termio) 383{ 384 struct termio v; 385 386 if (copy_from_user(&v, termio, sizeof(struct termio))) 387 return -EFAULT; 388 389 termios->c_iflag = (0xffff0000 & termios->c_iflag) | v.c_iflag; 390 termios->c_oflag = (0xffff0000 & termios->c_oflag) | v.c_oflag; 391 termios->c_cflag = (0xffff0000 & termios->c_cflag) | v.c_cflag; 392 termios->c_lflag = (0xffff0000 & termios->c_lflag) | v.c_lflag; 393 termios->c_line = (0xffff0000 & termios->c_lflag) | v.c_line; 394 memcpy(termios->c_cc, v.c_cc, NCC); 395 return 0; 396} 397 398/* 399 * Translate a "termios" structure into a "termio". Ugh. 400 */ 401__weak int kernel_termios_to_user_termio(struct termio __user *termio, 402 struct ktermios *termios) 403{ 404 struct termio v; 405 memset(&v, 0, sizeof(struct termio)); 406 v.c_iflag = termios->c_iflag; 407 v.c_oflag = termios->c_oflag; 408 v.c_cflag = termios->c_cflag; 409 v.c_lflag = termios->c_lflag; 410 v.c_line = termios->c_line; 411 memcpy(v.c_cc, termios->c_cc, NCC); 412 return copy_to_user(termio, &v, sizeof(struct termio)); 413} 414 415#ifdef TCGETS2 416__weak int user_termios_to_kernel_termios(struct ktermios *k, 417 struct termios2 __user *u) 418{ 419 return copy_from_user(k, u, sizeof(struct termios2)); 420} 421__weak int kernel_termios_to_user_termios(struct termios2 __user *u, 422 struct ktermios *k) 423{ 424 return copy_to_user(u, k, sizeof(struct termios2)); 425} 426__weak int user_termios_to_kernel_termios_1(struct ktermios *k, 427 struct termios __user *u) 428{ 429 return copy_from_user(k, u, sizeof(struct termios)); 430} 431__weak int kernel_termios_to_user_termios_1(struct termios __user *u, 432 struct ktermios *k) 433{ 434 return copy_to_user(u, k, sizeof(struct termios)); 435} 436 437#else 438 439__weak int user_termios_to_kernel_termios(struct ktermios *k, 440 struct termios __user *u) 441{ 442 return copy_from_user(k, u, sizeof(struct termios)); 443} 444__weak int kernel_termios_to_user_termios(struct termios __user *u, 445 struct ktermios *k) 446{ 447 return copy_to_user(u, k, sizeof(struct termios)); 448} 449#endif /* TCGETS2 */ 450 |
|
377/** 378 * set_termios - set termios values for a tty 379 * @tty: terminal device 380 * @arg: user data 381 * @opt: option information 382 * 383 * Helper function to prepare termios data and run necessary other 384 * functions before using tty_set_termios to do the actual changes. --- 524 unchanged lines hidden --- | 451/** 452 * set_termios - set termios values for a tty 453 * @tty: terminal device 454 * @arg: user data 455 * @opt: option information 456 * 457 * Helper function to prepare termios data and run necessary other 458 * functions before using tty_set_termios to do the actual changes. --- 524 unchanged lines hidden --- |