Skip to content

Commit 28bc24f

Browse files
Jiri Slabygregkh
authored andcommitted
vc: separate state
There are two copies of some members of struct vc_data. This is because we need to save them and restore later. Move these memebers to a separate structure called vc_state. So now instead of members like: vc_x, vc_y and vc_saved_x, vc_saved_y we have state and saved_state (of type: struct vc_state) containing state.x, state.y and saved_state.x, saved_state.y This change: * makes clear what is saved & restored * eases save & restore by using memcpy (see save_cur and restore_cur) Finally, we document the newly added struct vc_state using kernel-doc. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200615074910.19267-1-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 96564ac commit 28bc24f

13 files changed

Lines changed: 239 additions & 240 deletions

File tree

‎drivers/accessibility/braille/braille_console.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ static void braille_write(u16 *buf)
109109
/* Follow the VC cursor*/
110110
static void vc_follow_cursor(struct vc_data *vc)
111111
{
112-
vc_x = vc->vc_x - (vc->vc_x % WIDTH);
113-
vc_y = vc->vc_y;
114-
lastvc_x = vc->vc_x;
115-
lastvc_y = vc->vc_y;
112+
vc_x = vc->state.x - (vc->state.x % WIDTH);
113+
vc_y = vc->state.y;
114+
lastvc_x = vc->state.x;
115+
lastvc_y = vc->state.y;
116116
}
117117

118118
/* Maybe the VC cursor moved, if so follow it */
119119
static void vc_maybe_cursor_moved(struct vc_data *vc)
120120
{
121-
if (vc->vc_x != lastvc_x || vc->vc_y != lastvc_y)
121+
if (vc->state.x != lastvc_x || vc->state.y != lastvc_y)
122122
vc_follow_cursor(vc);
123123
}
124124

‎drivers/staging/speakup/main.c‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ static unsigned char get_attributes(struct vc_data *vc, u16 *pos)
263263

264264
static void speakup_date(struct vc_data *vc)
265265
{
266-
spk_x = spk_cx = vc->vc_x;
267-
spk_y = spk_cy = vc->vc_y;
266+
spk_x = spk_cx = vc->state.x;
267+
spk_y = spk_cy = vc->state.y;
268268
spk_pos = spk_cp = vc->vc_pos;
269269
spk_old_attr = spk_attr;
270270
spk_attr = get_attributes(vc, (u_short *)spk_pos);
@@ -1551,9 +1551,9 @@ static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag)
15511551
*/
15521552
is_cursor = value + 1;
15531553
old_cursor_pos = vc->vc_pos;
1554-
old_cursor_x = vc->vc_x;
1555-
old_cursor_y = vc->vc_y;
1556-
speakup_console[vc->vc_num]->ht.cy = vc->vc_y;
1554+
old_cursor_x = vc->state.x;
1555+
old_cursor_y = vc->state.y;
1556+
speakup_console[vc->vc_num]->ht.cy = vc->state.y;
15571557
cursor_con = vc->vc_num;
15581558
if (cursor_track == CT_Highlight)
15591559
reset_highlight_buffers(vc);
@@ -1574,8 +1574,8 @@ static void update_color_buffer(struct vc_data *vc, const u16 *ic, int len)
15741574
i = 0;
15751575
if (speakup_console[vc_num]->ht.highsize[bi] == 0) {
15761576
speakup_console[vc_num]->ht.rpos[bi] = vc->vc_pos;
1577-
speakup_console[vc_num]->ht.rx[bi] = vc->vc_x;
1578-
speakup_console[vc_num]->ht.ry[bi] = vc->vc_y;
1577+
speakup_console[vc_num]->ht.rx[bi] = vc->state.x;
1578+
speakup_console[vc_num]->ht.ry[bi] = vc->state.y;
15791579
}
15801580
while ((hi < COLOR_BUFFER_SIZE) && (i < len)) {
15811581
if (ic[i] > 32) {
@@ -1664,9 +1664,9 @@ static int speak_highlight(struct vc_data *vc)
16641664
return 0;
16651665
hc = get_highlight_color(vc);
16661666
if (hc != -1) {
1667-
d = vc->vc_y - speakup_console[vc_num]->ht.cy;
1667+
d = vc->state.y - speakup_console[vc_num]->ht.cy;
16681668
if ((d == 1) || (d == -1))
1669-
if (speakup_console[vc_num]->ht.ry[hc] != vc->vc_y)
1669+
if (speakup_console[vc_num]->ht.ry[hc] != vc->state.y)
16701670
return 0;
16711671
spk_parked |= 0x01;
16721672
spk_do_flush();
@@ -1693,8 +1693,8 @@ static void cursor_done(struct timer_list *unused)
16931693
}
16941694
speakup_date(vc);
16951695
if (win_enabled) {
1696-
if (vc->vc_x >= win_left && vc->vc_x <= win_right &&
1697-
vc->vc_y >= win_top && vc->vc_y <= win_bottom) {
1696+
if (vc->state.x >= win_left && vc->state.x <= win_right &&
1697+
vc->state.y >= win_top && vc->state.y <= win_bottom) {
16981698
spk_keydown = 0;
16991699
is_cursor = 0;
17001700
goto out;
@@ -1757,7 +1757,7 @@ static void speakup_con_write(struct vc_data *vc, u16 *str, int len)
17571757
if (!spin_trylock_irqsave(&speakup_info.spinlock, flags))
17581758
/* Speakup output, discard */
17591759
return;
1760-
if (spk_bell_pos && spk_keydown && (vc->vc_x == spk_bell_pos - 1))
1760+
if (spk_bell_pos && spk_keydown && (vc->state.x == spk_bell_pos - 1))
17611761
bleep(3);
17621762
if ((is_cursor) || (cursor_track == read_all_mode)) {
17631763
if (cursor_track == CT_Highlight)
@@ -1766,8 +1766,8 @@ static void speakup_con_write(struct vc_data *vc, u16 *str, int len)
17661766
return;
17671767
}
17681768
if (win_enabled) {
1769-
if (vc->vc_x >= win_left && vc->vc_x <= win_right &&
1770-
vc->vc_y >= win_top && vc->vc_y <= win_bottom) {
1769+
if (vc->state.x >= win_left && vc->state.x <= win_right &&
1770+
vc->state.y >= win_top && vc->state.y <= win_bottom) {
17711771
spin_unlock_irqrestore(&speakup_info.spinlock, flags);
17721772
return;
17731773
}

0 commit comments

Comments
 (0)