diff options
author | Sven Schnelle <svens@linux.ibm.com> | 2022-11-29 11:19:09 +0100 |
---|---|---|
committer | Heiko Carstens <hca@linux.ibm.com> | 2023-01-09 14:34:02 +0100 |
commit | 0573fff2054ea25c463339f38fa6979e85668215 (patch) | |
tree | 213152ea9c7a55a3cbcef63cad354002c02fee21 /drivers/s390/char/con3270.c | |
parent | 18fc2e93b602d8def2b8d10492238aa40180d292 (diff) | |
download | linux-stable-0573fff2054ea25c463339f38fa6979e85668215.tar.gz linux-stable-0573fff2054ea25c463339f38fa6979e85668215.tar.bz2 linux-stable-0573fff2054ea25c463339f38fa6979e85668215.zip |
s390/con3270: reduce highlight width to 3 bits
With the previous change this reduces the size of struct tty3270_attribute
from four to two bytes. As we have this struct allocated for each character
cell, this saves quite some memory.
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'drivers/s390/char/con3270.c')
-rw-r--r-- | drivers/s390/char/con3270.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/drivers/s390/char/con3270.c b/drivers/s390/char/con3270.c index 698e0881319a..9ef689c47e0b 100644 --- a/drivers/s390/char/con3270.c +++ b/drivers/s390/char/con3270.c @@ -42,9 +42,13 @@ static int tty3270_max_index; static struct tty3270 *condev; static struct raw3270_fn tty3270_fn; +#define TTY3270_HIGHLIGHT_BLINK 1 +#define TTY3270_HIGHLIGHT_REVERSE 2 +#define TTY3270_HIGHLIGHT_UNDERSCORE 4 + struct tty3270_attribute { unsigned char alternate_charset:1; /* Graphics charset */ - unsigned char highlight; /* Blink/reverse/underscore */ + unsigned char highlight:3; /* Blink/reverse/underscore */ unsigned char f_color:4; /* Foreground color */ unsigned char b_color:4; /* Background color */ }; @@ -301,7 +305,7 @@ static int tty3270_required_length(struct tty3270 *tp, struct tty3270_line *line int i, flen = 3; /* Prefix (TO_SBA). */ flen += line->len; - highlight = TAX_RESET; + highlight = 0; f_color = TAC_RESET; b_color = TAC_RESET; @@ -321,7 +325,7 @@ static int tty3270_required_length(struct tty3270 *tp, struct tty3270_line *line if (cell->attributes.alternate_charset) flen += 1; /* TO_GE to switch to graphics extensions */ } - if (highlight != TAX_RESET) + if (highlight) flen += 3; /* TO_SA to reset hightlight. */ if (f_color != TAC_RESET) flen += 3; /* TO_SA to reset color. */ @@ -336,7 +340,7 @@ static int tty3270_required_length(struct tty3270 *tp, struct tty3270_line *line static char *tty3270_add_reset_attributes(struct tty3270 *tp, struct tty3270_line *line, char *cp, struct tty3270_attribute *attr) { - if (attr->highlight != TAX_RESET) + if (attr->highlight) cp = tty3270_add_sa(tp, cp, TAT_EXTHI, TAX_RESET); if (attr->f_color != TAC_RESET) cp = tty3270_add_sa(tp, cp, TAT_FGCOLOR, TAX_RESET); @@ -392,6 +396,12 @@ static char *tty3270_add_attributes(struct tty3270 *tp, struct tty3270_line *lin [9] = TAC_DEFAULT }; + const unsigned char highlights[8] = { + [TTY3270_HIGHLIGHT_BLINK] = TAX_BLINK, + [TTY3270_HIGHLIGHT_REVERSE] = TAX_REVER, + [TTY3270_HIGHLIGHT_UNDERSCORE] = TAX_UNDER, + }; + struct tty3270_cell *cell; int c, i; @@ -400,7 +410,7 @@ static char *tty3270_add_attributes(struct tty3270 *tp, struct tty3270_line *lin for (i = 0, cell = line->cells; i < line->len; i++, cell++) { if (cell->attributes.highlight != attr->highlight) { attr->highlight = cell->attributes.highlight; - cp = tty3270_add_sa(tp, cp, TAT_EXTHI, attr->highlight); + cp = tty3270_add_sa(tp, cp, TAT_EXTHI, highlights[attr->highlight]); } if (cell->attributes.f_color != attr->f_color) { attr->f_color = cell->attributes.f_color; @@ -1413,25 +1423,22 @@ static void tty3270_set_attributes(struct tty3270 *tp) break; /* Highlight. */ case 4: /* Start underlining. */ - tp->attributes.highlight = TAX_UNDER; + tp->attributes.highlight = TTY3270_HIGHLIGHT_UNDERSCORE; break; case 5: /* Start blink. */ - tp->attributes.highlight = TAX_BLINK; + tp->attributes.highlight = TTY3270_HIGHLIGHT_BLINK; break; case 7: /* Start reverse. */ - tp->attributes.highlight = TAX_REVER; + tp->attributes.highlight = TTY3270_HIGHLIGHT_REVERSE; break; case 24: /* End underlining */ - if (tp->attributes.highlight == TAX_UNDER) - tp->attributes.highlight = TAX_RESET; + tp->attributes.highlight &= ~TTY3270_HIGHLIGHT_UNDERSCORE; break; case 25: /* End blink. */ - if (tp->attributes.highlight == TAX_BLINK) - tp->attributes.highlight = TAX_RESET; + tp->attributes.highlight &= ~TTY3270_HIGHLIGHT_BLINK; break; case 27: /* End reverse. */ - if (tp->attributes.highlight == TAX_REVER) - tp->attributes.highlight = TAX_RESET; + tp->attributes.highlight &= ~TTY3270_HIGHLIGHT_REVERSE; break; /* Foreground color. */ case 30: /* Black */ |