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
706/* Structure of attributes is hardware-dependent */706/* Structure of attributes is hardware-dependent */
707 707
708static u8 build_attr(struct vc_data *vc, u8 _color,708static u8 build_attr(struct vc_data *vc, u8 _color,
709 enum vc_intensity _intensity, u8 _blink, u8 _underline,709 enum vc_intensity _intensity, bool _blink, bool _underline,
710 u8 _reverse, u8 _italic)710 bool _reverse, bool _italic)
711{711{
712 if (vc->vc_sw->con_build_attr)712 if (vc->vc_sw->con_build_attr)
713 return vc->vc_sw->con_build_attr(vc, _color, _intensity,713 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
755 vc->state.blink, vc->state.underline,755 vc->state.blink, vc->state.underline,
756 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic);756 vc->state.reverse ^ vc->vc_decscnm, vc->state.italic);
757 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color,757 vc->vc_video_erase_char = ' ' | (build_attr(vc, vc->state.color,
758 VCI_NORMAL, vc->state.blink, 0, vc->vc_decscnm,758 VCI_NORMAL, vc->state.blink, false,
759 0) << 8);759 vc->vc_decscnm, false) << 8);
760}760}
761 761
762/* Note: inverting the screen twice should revert to the original state */762/* 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
1614static void default_attr(struct vc_data *vc)1614static void default_attr(struct vc_data *vc)
1615{1615{
1616 vc->state.intensity = VCI_NORMAL;1616 vc->state.intensity = VCI_NORMAL;
1617 vc->state.italic = 0;1617 vc->state.italic = false;
1618 vc->state.underline = 0;1618 vc->state.underline = false;
1619 vc->state.reverse = 0;1619 vc->state.reverse = false;
1620 vc->state.blink = 0;1620 vc->state.blink = false;
1621 vc->state.color = vc->vc_def_color;1621 vc->state.color = vc->vc_def_color;
1622}1622}
1623 1623
@@ -1723,7 +1723,7 @@ static void csi_m(struct vc_data *vc) · 99 unmodified lines
1723 vc->state.intensity = VCI_HALF_BRIGHT;1723 vc->state.intensity = VCI_HALF_BRIGHT;
1724 break;1724 break;
1725 case 3:1725 case 3:
1726 vc->state.italic = 1;1726 vc->state.italic = true;
1727 break;1727 break;
1728 case 21:1728 case 21:
1729 /*1729 /*
@@ -1731,13 +1731,13 @@ static void csi_m(struct vc_data *vc) · 1 unmodified line
1731 * convert it to a single underline.1731 * convert it to a single underline.
1732 */1732 */
1733 case 4:1733 case 4:
1734 vc->state.underline = 1;1734 vc->state.underline = true;
1735 break;1735 break;
1736 case 5:1736 case 5:
1737 vc->state.blink = 1;1737 vc->state.blink = true;
1738 break;1738 break;
1739 case 7:1739 case 7:
1740 vc->state.reverse = 1;1740 vc->state.reverse = true;
1741 break;1741 break;
1742 case 10: /* ANSI X3.64-1979 (SCO-ish?)1742 case 10: /* ANSI X3.64-1979 (SCO-ish?)
1743 * Select primary font, don't display control chars if1743 * Select primary font, don't display control chars if
@@ -1769,16 +1769,16 @@ static void csi_m(struct vc_data *vc) · 25 unmodified lines
1769 vc->state.intensity = VCI_NORMAL;1769 vc->state.intensity = VCI_NORMAL;
1770 break;1770 break;
1771 case 23:1771 case 23:
1772 vc->state.italic = 0;1772 vc->state.italic = false;
1773 break;1773 break;
1774 case 24:1774 case 24:
1775 vc->state.underline = 0;1775 vc->state.underline = false;
1776 break;1776 break;
1777 case 25:1777 case 25:
1778 vc->state.blink = 0;1778 vc->state.blink = false;
1779 break;1779 break;
1780 case 27:1780 case 27:
1781 vc->state.reverse = 0;1781 vc->state.reverse = false;
1782 break;1782 break;
1783 case 38:1783 case 38:
1784 i = vc_t416_color(vc, i, rgb_foreground);1784 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
303/* interface routine */303/* interface routine */
304static u8304static u8
305sisusbcon_build_attr(struct vc_data *c, u8 color, enum vc_intensity intensity,305sisusbcon_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)
307{308{
308 u8 attr = color;309 u8 attr = color;
309 310
drivers/video/console/mdacon.c+6−5
@@ -396,7 +396,8 @@ static inline u16 mda_convert_attr(u16 ch) · 395 unmodified lines
396 396
397static u8 mdacon_build_attr(struct vc_data *c, u8 color,397static u8 mdacon_build_attr(struct vc_data *c, u8 color,
398 enum vc_intensity intensity,398 enum vc_intensity intensity,
399 u8 blink, u8 underline, u8 reverse, u8 italic)399 bool blink, bool underline, bool reverse,
400 bool italic)
400{401{
401 /* The attribute is just a bit vector:402 /* The attribute is just a bit vector:
402 *403 *
@@ -407,10 +408,10 @@ static u8 mdacon_build_attr(struct vc_data *c, u8 color, · 4 unmodified lines
407 */408 */
408 409
409 return (intensity & VCI_MASK) |410 return (intensity & VCI_MASK) |
410 ((underline & 1) << 2) |411 (underline << 2) |
411 ((reverse & 1) << 3) |412 (reverse << 3) |
412 (!!italic << 4) |413 (italic << 4) |
413 ((blink & 1) << 7);414 (blink << 7);
414}415}
415 416
416static void mdacon_invert_region(struct vc_data *c, u16 *p, int count)417static 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
290 290
291static u8 sticon_build_attr(struct vc_data *conp, u8 color,291static u8 sticon_build_attr(struct vc_data *conp, u8 color,
292 enum vc_intensity intens,292 enum vc_intensity intens,
293 u8 blink, u8 underline, u8 reverse, u8 italic)293 bool blink, bool underline, bool reverse,
294 bool italic)
294{295{
295 u8 attr = ((color & 0x70) >> 1) | ((color & 7));296 u8 attr = ((color & 0x70) >> 1) | ((color & 7));
296 297
drivers/video/console/vgacon.c+2−1
@@ -631,7 +631,8 @@ static void vgacon_deinit(struct vc_data *c) · 630 unmodified lines
631 631
632static u8 vgacon_build_attr(struct vc_data *c, u8 color,632static u8 vgacon_build_attr(struct vc_data *c, u8 color,
633 enum vc_intensity intensity,633 enum vc_intensity intensity,
634 u8 blink, u8 underline, u8 reverse, u8 italic)634 bool blink, bool underline, bool reverse,
635 bool italic)
635{636{
636 u8 attr = color;637 u8 attr = color;
637 638
include/linux/console.h+1−1
@@ -78,7 +78,7 @@ struct consw { · 77 unmodified lines
78 void (*con_save_screen)(struct vc_data *vc);78 void (*con_save_screen)(struct vc_data *vc);
79 u8 (*con_build_attr)(struct vc_data *vc, u8 color,79 u8 (*con_build_attr)(struct vc_data *vc, u8 color,
80 enum vc_intensity intensity,80 enum vc_intensity intensity,
81 u8 blink, u8 underline, u8 reverse, u8 italic);81 bool blink, bool underline, bool reverse, bool italic);
82 void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);82 void (*con_invert_region)(struct vc_data *vc, u16 *p, int count);
83 u16 *(*con_screen_pos)(struct vc_data *vc, int offset);83 u16 *(*con_screen_pos)(struct vc_data *vc, int offset);
84 unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position,84 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
54 54
55 /* attribute flags */55 /* attribute flags */
56 enum vc_intensity intensity;56 enum vc_intensity intensity;
57 unsigned int italic : 1;57 bool italic;
58 unsigned int underline : 1;58 bool underline;
59 unsigned int blink : 1;59 bool blink;
60 unsigned int reverse : 1;60 bool reverse;
61};61};
62 62
63/*63/*