Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/termios.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/tty.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * Routine which returns the baud rate of the tty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * Note that the baud_table needs to be kept in sync with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * include/asm/termbits.h file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static const speed_t baud_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #ifdef __sparc__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	76800, 153600, 307200, 614400, 921600, 500000, 576000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	1000000, 1152000, 1500000, 2000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	2500000, 3000000, 3500000, 4000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static const tcflag_t baud_bits[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	B0, B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	B4800, B9600, B19200, B38400, B57600, B115200, B230400, B460800,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #ifdef __sparc__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	B76800, B153600, B307200, B614400, B921600, B500000, B576000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	B1000000, B1152000, B1500000, B2000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	B500000, B576000, B921600, B1000000, B1152000, B1500000, B2000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	B2500000, B3000000, B3500000, B4000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static int n_baud_table = ARRAY_SIZE(baud_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  *	tty_termios_baud_rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *	@termios: termios structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  *	Convert termios baud rate data into a speed. This should be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  *	with the termios lock held if this termios is a terminal termios
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  *	structure. May change the termios data. Device drivers can call this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  *	function but should use ->c_[io]speed directly as they are updated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *	Locking: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) speed_t tty_termios_baud_rate(struct ktermios *termios)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	unsigned int cbaud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	cbaud = termios->c_cflag & CBAUD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #ifdef BOTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	/* Magic token for arbitrary speed via c_ispeed/c_ospeed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (cbaud == BOTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		return termios->c_ospeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	if (cbaud & CBAUDEX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		cbaud &= ~CBAUDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		if (cbaud < 1 || cbaud + 15 > n_baud_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			termios->c_cflag &= ~CBAUDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			cbaud += 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) EXPORT_SYMBOL(tty_termios_baud_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  *	tty_termios_input_baud_rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  *	@termios: termios structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  *	Convert termios baud rate data into a speed. This should be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  *	with the termios lock held if this termios is a terminal termios
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  *	structure. May change the termios data. Device drivers can call this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  *	function but should use ->c_[io]speed directly as they are updated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  *	Locking: none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) speed_t tty_termios_input_baud_rate(struct ktermios *termios)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #ifdef IBSHIFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (cbaud == B0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return tty_termios_baud_rate(termios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) #ifdef BOTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	/* Magic token for arbitrary speed via c_ispeed*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (cbaud == BOTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		return termios->c_ispeed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	if (cbaud & CBAUDEX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		cbaud &= ~CBAUDEX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		if (cbaud < 1 || cbaud + 15 > n_baud_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			termios->c_cflag &= ~(CBAUDEX << IBSHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			cbaud += 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #else	/* IBSHIFT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return tty_termios_baud_rate(termios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #endif	/* IBSHIFT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) EXPORT_SYMBOL(tty_termios_input_baud_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *	tty_termios_encode_baud_rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  *	@termios: ktermios structure holding user requested state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *	@ibaud: input speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *	@obaud: output speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  *	Encode the speeds set into the passed termios structure. This is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *	used as a library helper for drivers so that they can report back
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *	the actual speed selected when it differs from the speed requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  *	For maximal back compatibility with legacy SYS5/POSIX *nix behaviour
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *	we need to carefully set the bits when the user does not get the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  *	desired speed. We allow small margins and preserve as much of possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  *	of the input intent to keep compatibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  *	Locking: Caller should hold termios lock. This is already held
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  *	when calling this function from the driver termios handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  *	The ifdefs deal with platforms whose owners have yet to update them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  *	and will all go away once this is done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void tty_termios_encode_baud_rate(struct ktermios *termios,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 				  speed_t ibaud, speed_t obaud)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	int ifound = -1, ofound = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	int iclose = ibaud/50, oclose = obaud/50;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	int ibinput = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	if (obaud == 0)			/* CD dropped 		  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		ibaud = 0;		/* Clear ibaud to be sure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	termios->c_ispeed = ibaud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	termios->c_ospeed = obaud;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #ifdef IBSHIFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	if ((termios->c_cflag >> IBSHIFT) & CBAUD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		ibinput = 1;	/* An input speed was specified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #ifdef BOTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/* If the user asked for a precise weird speed give a precise weird
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	   answer. If they asked for a Bfoo speed they may have problems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	   digesting non-exact replies so fuzz a bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if ((termios->c_cflag & CBAUD) == BOTHER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		oclose = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		if (!ibinput)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 			iclose = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		iclose = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	termios->c_cflag &= ~CBAUD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #ifdef IBSHIFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	termios->c_cflag &= ~(CBAUD << IBSHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	 *	Our goal is to find a close match to the standard baud rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 *	returned. Walk the baud rate table and if we get a very close
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 *	match then report back the speed as a POSIX Bxxxx value by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 *	preference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		if (obaud - oclose <= baud_table[i] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		    obaud + oclose >= baud_table[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			termios->c_cflag |= baud_bits[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			ofound = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		if (ibaud - iclose <= baud_table[i] &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		    ibaud + iclose >= baud_table[i]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 			/* For the case input == output don't set IBAUD bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			   if the user didn't do so */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			if (ofound == i && !ibinput)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				ifound  = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #ifdef IBSHIFT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 			else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 				ifound = i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 				termios->c_cflag |= (baud_bits[i] << IBSHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	} while (++i < n_baud_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	 *	If we found no match then use BOTHER if provided or warn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	 *	the user their platform maintainer needs to wake up if not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) #ifdef BOTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (ofound == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		termios->c_cflag |= BOTHER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	/* Set exact input bits only if the input and output differ or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	   user already did */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	if (ifound == -1 && (ibaud != obaud || ibinput))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		termios->c_cflag |= (BOTHER << IBSHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (ifound == -1 || ofound == -1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		pr_warn_once("tty: Unable to return correct speed data as your architecture needs updating.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  *	tty_encode_baud_rate		-	set baud rate of the tty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)  *	@ibaud: input baud rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)  *	@obaud: output baud rate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  *	Update the current termios data for the tty with the new speed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  *	settings. The caller must hold the termios_rwsem for the tty in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  *	question.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	tty_termios_encode_baud_rate(&tty->termios, ibaud, obaud);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) EXPORT_SYMBOL_GPL(tty_encode_baud_rate);