]> www.infradead.org Git - users/jedix/linux-maple.git/commit
n_tty: Use DIV_ROUND_UP() in room calculation
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 9 Mar 2023 08:20:32 +0000 (10:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 14:01:08 +0000 (15:01 +0100)
commit7e26c84d02d17e7412e6f2471916fd415654a1ba
tree45dad8770275398807603351ced02b55b6383e20
parent9db1be84054b7445f911b9efe9bc3c924ffdb543
n_tty: Use DIV_ROUND_UP() in room calculation

When PARMRK is set, a character can result in up to 3 chars in the read
buffer. Receive code calculates for how many characters there (at
least) is room. Convert an opencoded rounding in the calculation to use
DIV_ROUND_UP().

Note: the room variable is decremented afterwards by one which ensures
the characters will fit into the buffer for real so the code is okay
despite rounding upwards.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230309082035.14880-6-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_tty.c