[Devel] [PATCH RHEL9 COMMIT] ms/tty: Remove baudrate dead code & make ktermios params const
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Nov 3 21:03:16 MSK 2023
The commit is pushed to "branch-rh9-5.14.0-284.25.1.vz9.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-284.25.1.vz9.30.10
------>
commit a485abe5e4d26a162d7864ebc4184127111ac0fe
Author: Ilpo Järvinen <ilpo.jarvinen at linux.intel.com>
Date: Tue Aug 16 14:57:32 2022 +0300
ms/tty: Remove baudrate dead code & make ktermios params const
With the architectures currently in-tree, either:
1) CBAUDEX is zero
2) The earlier BOTHER if check covers cbaud < 1 case
3) All CBAUD bits are covered by the baud_table
Thus, the check for cbaud being out-of-range for CBAUDEX case cannot
ever be true.
The ktermios parameters can now be made const.
Reviewed-by: Andy Shevchenko <andy.shevchenko at gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen at linux.intel.com>
Link: https://lore.kernel.org/r/20220816115739.10928-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
Getting rid of compilation warnings.
https://virtuozzo.atlassian.net/browse/PSBM-148793
Feature: fix ms/drivers
(cherry picked from commit 87888fb9ac0c71cdc1edd0779382052475dadb84)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
drivers/tty/tty.h | 2 +-
drivers/tty/tty_baudrate.c | 24 ++++++++----------------
include/linux/tty.h | 2 +-
3 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h
index f310a8274df1..1c08c9b67b16 100644
--- a/drivers/tty/tty.h
+++ b/drivers/tty/tty.h
@@ -73,7 +73,7 @@ void tty_buffer_set_lock_subclass(struct tty_port *port);
bool tty_buffer_restart_work(struct tty_port *port);
bool tty_buffer_cancel_work(struct tty_port *port);
void tty_buffer_flush_work(struct tty_port *port);
-speed_t tty_termios_input_baud_rate(struct ktermios *termios);
+speed_t tty_termios_input_baud_rate(const struct ktermios *termios);
void tty_ldisc_hangup(struct tty_struct *tty, bool reset);
int tty_ldisc_reinit(struct tty_struct *tty, int disc);
long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index 426b1252781a..e1d3c68a0b2c 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -49,13 +49,13 @@ static int n_baud_table = ARRAY_SIZE(baud_table);
*
* Convert termios baud rate data into a speed. This should be called
* with the termios lock held if this termios is a terminal termios
- * structure. May change the termios data. Device drivers can call this
- * function but should use ->c_[io]speed directly as they are updated.
+ * structure. Device drivers can call this function but should use
+ * ->c_[io]speed directly as they are updated.
*
* Locking: none
*/
-speed_t tty_termios_baud_rate(struct ktermios *termios)
+speed_t tty_termios_baud_rate(const struct ktermios *termios)
{
unsigned int cbaud;
@@ -68,11 +68,7 @@ speed_t tty_termios_baud_rate(struct ktermios *termios)
#endif
if (cbaud & CBAUDEX) {
cbaud &= ~CBAUDEX;
-
- if (cbaud < 1 || cbaud + 15 > n_baud_table)
- termios->c_cflag &= ~CBAUDEX;
- else
- cbaud += 15;
+ cbaud += 15;
}
return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
}
@@ -84,13 +80,13 @@ EXPORT_SYMBOL(tty_termios_baud_rate);
*
* Convert termios baud rate data into a speed. This should be called
* with the termios lock held if this termios is a terminal termios
- * structure. May change the termios data. Device drivers can call this
- * function but should use ->c_[io]speed directly as they are updated.
+ * structure. Device drivers can call this function but should use
+ * ->c_[io]speed directly as they are updated.
*
* Locking: none
*/
-speed_t tty_termios_input_baud_rate(struct ktermios *termios)
+speed_t tty_termios_input_baud_rate(const struct ktermios *termios)
{
#ifdef IBSHIFT
unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
@@ -104,11 +100,7 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
#endif
if (cbaud & CBAUDEX) {
cbaud &= ~CBAUDEX;
-
- if (cbaud < 1 || cbaud + 15 > n_baud_table)
- termios->c_cflag &= ~(CBAUDEX << IBSHIFT);
- else
- cbaud += 15;
+ cbaud += 15;
}
return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
#else /* IBSHIFT */
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 33572a5a5538..71bff77266f1 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -474,7 +474,7 @@ extern int tty_hung_up_p(struct file *filp);
extern void do_SAK(struct tty_struct *tty);
extern void __do_SAK(struct tty_struct *tty);
extern void no_tty(void);
-extern speed_t tty_termios_baud_rate(struct ktermios *termios);
+extern speed_t tty_termios_baud_rate(const struct ktermios *termios);
extern void tty_termios_encode_baud_rate(struct ktermios *termios,
speed_t ibaud, speed_t obaud);
extern void tty_encode_baud_rate(struct tty_struct *tty,
More information about the Devel
mailing list