diff options
author | Jiri Slaby <jslaby@suse.cz> | 2022-06-14 12:05:35 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-06-27 15:17:12 +0300 |
commit | 1c2f6294a3613b84fc20d6620da078dedbb2ac1e (patch) | |
tree | f07f5cdd18a232381033ab219873f555ebd6025d /drivers/tty/vt/consolemap.c | |
parent | 8da443b1a4036b5863fd2ec7e0251164b704c726 (diff) | |
download | linux-1c2f6294a3613b84fc20d6620da078dedbb2ac1e.tar.xz |
tty/vt: consolemap: improve UNI_*() macros definitions
Use FIELD_GET() and GENMASK() helpers instead of direct shifts and ANDs.
This makes the code even more obvious. I didn't know about the helpers
at the time of writing the macros.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220614090537.15557-6-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/vt/consolemap.c')
-rw-r--r-- | drivers/tty/vt/consolemap.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 16d0d8f04f0e..9e94ec0e0f83 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -23,6 +23,8 @@ * stack overflow. */ +#include <linux/bitfield.h> +#include <linux/bits.h> #include <linux/module.h> #include <linux/kd.h> #include <linux/errno.h> @@ -190,10 +192,17 @@ static enum translation_map inv_translate[MAX_NR_CONSOLES]; #define UNI_DIR_ROWS 32U #define UNI_ROW_GLYPHS 64U -#define UNI_DIR(uni) ( (uni) >> 11) -#define UNI_ROW(uni) (((uni) & GENMASK(10, 6)) >> 6) -#define UNI_GLYPH(uni) ( (uni) & GENMASK( 5, 0)) -#define UNI(dir, row, glyph) (((dir) << 11) | ((row) << 6) | (glyph)) +#define UNI_DIR_BITS GENMASK(15, 11) +#define UNI_ROW_BITS GENMASK(10, 6) +#define UNI_GLYPH_BITS GENMASK( 5, 0) + +#define UNI_DIR(uni) FIELD_GET(UNI_DIR_BITS, (uni)) +#define UNI_ROW(uni) FIELD_GET(UNI_ROW_BITS, (uni)) +#define UNI_GLYPH(uni) FIELD_GET(UNI_GLYPH_BITS, (uni)) + +#define UNI(dir, row, glyph) (FIELD_PREP(UNI_DIR_BITS, (dir)) | \ + FIELD_PREP(UNI_ROW_BITS, (row)) | \ + FIELD_PREP(UNI_GLYPH_BITS, (glyph))) /** * struct uni_pagedict -- unicode directory |