aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/console
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2014-05-13 06:09:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-05-28 16:37:21 -0400
commit0f2893f0d1acff4bb1677b60c0486adc0075cb99 (patch)
tree54cb081d1b15bd1fd5d5c80f4f29ccea040423f7 /drivers/video/console
parent4061f4987b45d8d4126a57c8333cb3a8aeb3e08a (diff)
vgacon: Fix & cleanup refcounting
The vgacon driver prepares a two element array of uni_pagedir_loc and uses the second item as its own reference counter for sharing the uni_pagedir. And the code assumes blindly that the second item is available if the assigned vc_uni_pagedir isn't the standard one, which might be wrong (although currently it's so). This patch fixes that wrong assumption, and gives a slight cleanup along with it: namely, instead of array, just give the uni_pagedir_loc and a separate refcount variable. It makes the code a bit more understandable at first glance. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/video/console')
-rw-r--r--drivers/video/console/vgacon.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 9d8feac67637..9e18770aaba6 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -87,7 +87,8 @@ static void vgacon_save_screen(struct vc_data *c);
87static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, 87static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
88 int lines); 88 int lines);
89static void vgacon_invert_region(struct vc_data *c, u16 * p, int count); 89static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
90static unsigned long vgacon_uni_pagedir[2]; 90static unsigned long vgacon_uni_pagedir;
91static int vgacon_refcount;
91 92
92/* Description of the hardware situation */ 93/* Description of the hardware situation */
93static int vga_init_done __read_mostly; 94static int vga_init_done __read_mostly;
@@ -575,12 +576,12 @@ static void vgacon_init(struct vc_data *c, int init)
575 if (vga_512_chars) 576 if (vga_512_chars)
576 c->vc_hi_font_mask = 0x0800; 577 c->vc_hi_font_mask = 0x0800;
577 p = *c->vc_uni_pagedir_loc; 578 p = *c->vc_uni_pagedir_loc;
578 if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir || 579 if (c->vc_uni_pagedir_loc != &vgacon_uni_pagedir) {
579 !--c->vc_uni_pagedir_loc[1])
580 con_free_unimap(c); 580 con_free_unimap(c);
581 c->vc_uni_pagedir_loc = vgacon_uni_pagedir; 581 c->vc_uni_pagedir_loc = &vgacon_uni_pagedir;
582 vgacon_uni_pagedir[1]++; 582 vgacon_refcount++;
583 if (!vgacon_uni_pagedir[0] && p) 583 }
584 if (!vgacon_uni_pagedir && p)
584 con_set_default_unimap(c); 585 con_set_default_unimap(c);
585 586
586 /* Only set the default if the user didn't deliberately override it */ 587 /* Only set the default if the user didn't deliberately override it */
@@ -597,7 +598,7 @@ static void vgacon_deinit(struct vc_data *c)
597 vga_set_mem_top(c); 598 vga_set_mem_top(c);
598 } 599 }
599 600
600 if (!--vgacon_uni_pagedir[1]) 601 if (!--vgacon_refcount)
601 con_free_unimap(c); 602 con_free_unimap(c);
602 c->vc_uni_pagedir_loc = &c->vc_uni_pagedir; 603 c->vc_uni_pagedir_loc = &c->vc_uni_pagedir;
603 con_set_default_unimap(c); 604 con_set_default_unimap(c);