Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mxs-auart: redefine AUART_LINECTRL_WLEN to accept bits count

It's a bit illogical to take magic constants in AUART_LINECTRL_WLEN.
Like in auart_console_get_options(), 2 means 7 bits. Switch
AUART_LINECTRL_WLEN to accept bit length, i.e. let it subtract 5 from
the parameter before doing the logic.

This will ease conversion from CSIZE to bits in mxs_auart_settermios()
in the next patch.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210610090247.2593-2-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
8ea43acc 654ee49b

+6 -6
+6 -6
drivers/tty/serial/mxs-auart.c
··· 87 87 #define AUART_LINECTRL_BAUD_DIVFRAC(v) (((v) & 0x3f) << 8) 88 88 #define AUART_LINECTRL_SPS (1 << 7) 89 89 #define AUART_LINECTRL_WLEN_MASK 0x00000060 90 - #define AUART_LINECTRL_WLEN(v) (((v) & 0x3) << 5) 90 + #define AUART_LINECTRL_WLEN(v) ((((v) - 5) & 0x3) << 5) 91 91 #define AUART_LINECTRL_FEN (1 << 4) 92 92 #define AUART_LINECTRL_STP2 (1 << 3) 93 93 #define AUART_LINECTRL_EPS (1 << 2) ··· 973 973 /* byte size */ 974 974 switch (cflag & CSIZE) { 975 975 case CS5: 976 - bm = 0; 976 + bm = 5; 977 977 break; 978 978 case CS6: 979 - bm = 1; 979 + bm = 6; 980 980 break; 981 981 case CS7: 982 - bm = 2; 982 + bm = 7; 983 983 break; 984 984 case CS8: 985 - bm = 3; 985 + bm = 8; 986 986 break; 987 987 default: 988 988 return; ··· 1403 1403 *parity = 'o'; 1404 1404 } 1405 1405 1406 - if ((lcr_h & AUART_LINECTRL_WLEN_MASK) == AUART_LINECTRL_WLEN(2)) 1406 + if ((lcr_h & AUART_LINECTRL_WLEN_MASK) == AUART_LINECTRL_WLEN(7)) 1407 1407 *bits = 7; 1408 1408 else 1409 1409 *bits = 8;