History

vc: switch state to bool

The code currently uses bitfields to store true-false values. Switch all of that to bools. Apart from the cleanup, it saves 20B of code as many shifts, ANDs, and ORs became simple movzb's.

Jiri Slaby committed 6 years ago

Commit 77bc14f1 parent b84ae3d7 files · +33 −29Browse files

Unified · Split

7 files
  1. drivers/tty/vt/vt.c +16 −16
  2. drivers/usb/misc/sisusbvga/sisusb_con.c +2 −1
  3. drivers/video/console/mdacon.c +6 −5
  4. drivers/video/console/sticon.c +2 −1
  5. drivers/video/console/vgacon.c +2 −1
  6. include/linux/console.h +1 −1
  7. include/linux/console_struct.h +4 −4
drivers/tty/vt/vt.c+16−16
@@ -706,8 +706,8 @@ void update_region(struct vc_data *vc, unsigned long start, int count) · 705 unmodified lines
706706 /* Structure of attributes is hardware-dependent */
707707
708708 static u8 build_attr(struct vc_data *vc, u8 _color,
709− enum vc_intensity _intensity, u8 _blink, u8 _underline,
710− u8 _reverse, u8 _italic)
709+ enum vc_intensity _intensity, bool _blink, bool _underline,
710+ bool _reverse, bool _italic)
711711 {
712712 if (vc->vc_sw->con_build_attr)
713713 return vc->vc_sw->con_build_attr(vc, _color, _intensity,
@@ -755,8 +755,8 @@ static void update_attr(struct vc_data *vc) · 41 unmodified lines
755755 vc->state.blink, vc->state.underline,
756756 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic);
757757 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color,
758− VCI_NORMAL, vc->state.blink, 0, vc->vc_decscnm,
759− 0) << 8);
758+ VCI_NORMAL, vc->state.blink, false,
759+ vc->vc_decscnm, false) << 8);
760760 }
761761
762762 /* Note: inverting the screen twice should revert to the original state */
@@ -1614,10 +1614,10 @@ static void csi_X(struct vc_data *vc, int vpar) /* erase the following vpar posi · 851 unmodified lines
16141614 static void default_attr(struct vc_data *vc)
16151615 {
16161616 vc->state.intensity = VCI_NORMAL;
1617− vc->state.italic = 0;
1618− vc->state.underline = 0;
1619− vc->state.reverse = 0;
1620− vc->state.blink = 0;
1617+ vc->state.italic = false;
1618+ vc->state.underline = false;
1619+ vc->state.reverse = false;
1620+ vc->state.blink = false;
16211621 vc->state.color = vc->vc_def_color;
16221622 }
16231623
@@ -1723,7 +1723,7 @@ static void csi_m(struct vc_data *vc) · 99 unmodified lines
17231723 vc->state.intensity = VCI_HALF_BRIGHT;
17241724 break;
17251725 case 3:
1726− vc->state.italic = 1;
1726+ vc->state.italic = true;
17271727 break;
17281728 case 21:
17291729 /*
@@ -1731,13 +1731,13 @@ static void csi_m(struct vc_data *vc) · 1 unmodified line
17311731 * convert it to a single underline.
17321732 */
17331733 case 4:
1734− vc->state.underline = 1;
1734+ vc->state.underline = true;
17351735 break;
17361736 case 5:
1737− vc->state.blink = 1;
1737+ vc->state.blink = true;
17381738 break;
17391739 case 7:
1740− vc->state.reverse = 1;
1740+ vc->state.reverse = true;
17411741 break;
17421742 case 10: /* ANSI X3.64-1979 (SCO-ish?)
17431743 * Select primary font, don't display control chars if
@@ -1769,16 +1769,16 @@ static void csi_m(struct vc_data *vc) · 25 unmodified lines
17691769 vc->state.intensity = VCI_NORMAL;
17701770 break;
17711771 case 23:
1772− vc->state.italic = 0;
1772+ vc->state.italic = false;
17731773 break;
17741774 case 24:
1775− vc->state.underline = 0;
1775+ vc->state.underline = false;
17761776 break;
17771777 case 25:
1778− vc->state.blink = 0;
1778+ vc->state.blink = false;
17791779 break;
17801780 case 27:
1781− vc->state.reverse = 0;
1781+ vc->state.reverse = false;
17821782 break;
17831783 case 38:
17841784 i = vc_t416_color(vc, i, rgb_foreground);
drivers/usb/misc/sisusbvga/sisusb_con.c+2−1
@@ -303,7 +303,8 @@ sisusbcon_deinit(struct vc_data *c) · 302 unmodified lines
303303 /* interface routine */
304304 static u8
305305 sisusbcon_build_attr(struct vc_data *c, u8 color, enum vc_intensity intensity,
306− u8 blink, u8 underline, u8 reverse, u8 unused)
306+ bool blink, bool underline, bool reverse,
307+ bool unused)
307308 {
308309 u8 attr = color;
309310
drivers/video/console/mdacon.c+6−5
@@ -396,7 +396,8 @@ static inline u16 mda_convert_attr(u16 ch) · 395 unmodified lines
396396
397397 static u8 mdacon_build_attr(struct vc_data *c, u8 color,
398398 enum vc_intensity intensity,
399− u8 blink, u8 underline, u8 reverse, u8 italic)
399+ bool blink, bool underline, bool reverse,
400+ bool italic)
400401 {
401402 /* The attribute is just a bit vector:
402403 *
@@ -407,10 +408,10 @@ static u8 mdacon_build_attr(struct vc_data *c, u8 color, · 4 unmodified lines
407408 */
408409
409410 return (intensity & VCI_MASK) |
410− ((underline & 1) << 2) |
411− ((reverse & 1) << 3) |
412− (!!italic << 4) |
413− ((blink & 1) << 7);
411+ (underline << 2) |
412+ (reverse << 3) |
413+ (italic << 4) |
414+ (blink << 7);
414415 }
415416
416417 static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)
drivers/video/console/sticon.c+2−1
@@ -290,7 +290,8 @@ static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos, · 289 unmodified lines
290290
291291 static u8 sticon_build_attr(struct vc_data *conp, u8 color,
292292 enum vc_intensity intens,
293− u8 blink, u8 underline, u8 reverse, u8 italic)
293+ bool blink, bool underline, bool reverse,
294+ bool italic)
294295 {
295296 u8 attr = ((color & 0x70) >> 1) | ((color & 7));
296297
drivers/video/console/vgacon.c+2−1
@@ -631,7 +631,8 @@ static void vgacon_deinit(struct vc_data *c) · 630 unmodified lines
631631
632632 static u8 vgacon_build_attr(struct vc_data *c, u8 color,
633633 enum vc_intensity intensity,
634− u8 blink, u8 underline, u8 reverse, u8 italic)
634+ bool blink, bool underline, bool reverse,
635+ bool italic)
635636 {
636637 u8 attr = color;
637638
include/linux/console.h+1−1
@@ -78,7 +78,7 @@ struct consw { · 77 unmodified lines
7878 void (*con_save_screen)(struct vc_data *vc);
7979 u8 (*con_build_attr)(struct vc_data *vc, u8 color,
8080 enum vc_intensity intensity,
81− u8 blink, u8 underline, u8 reverse, u8 italic);
81+ bool blink, bool underline, bool reverse, bool italic);
8282 void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
8383 u16 *(*con_screen_pos)(struct vc_data *vc, int offset);
8484 unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position,
include/linux/console_struct.h+4−4
@@ -54,10 +54,10 @@ struct vc_state { · 53 unmodified lines
5454
5555 /* attribute flags */
5656 enum vc_intensity intensity;
57− unsigned int italic : 1;
58− unsigned int underline : 1;
59− unsigned int blink : 1;
60− unsigned int reverse : 1;
57+ bool italic;
58+ bool underline;
59+ bool blink;
60+ bool reverse;
6161 };
6262
6363 /*