Commit 0f2893f0 authored by Takashi Iwai's avatar Takashi Iwai Committed by Greg Kroah-Hartman

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: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4061f498
...@@ -87,7 +87,8 @@ static void vgacon_save_screen(struct vc_data *c); ...@@ -87,7 +87,8 @@ static void vgacon_save_screen(struct vc_data *c);
static int vgacon_scroll(struct vc_data *c, int t, int b, int dir, static int vgacon_scroll(struct vc_data *c, int t, int b, int dir,
int lines); int lines);
static void vgacon_invert_region(struct vc_data *c, u16 * p, int count); static void vgacon_invert_region(struct vc_data *c, u16 * p, int count);
static unsigned long vgacon_uni_pagedir[2]; static unsigned long vgacon_uni_pagedir;
static int vgacon_refcount;
/* Description of the hardware situation */ /* Description of the hardware situation */
static int vga_init_done __read_mostly; static int vga_init_done __read_mostly;
...@@ -575,12 +576,12 @@ static void vgacon_init(struct vc_data *c, int init) ...@@ -575,12 +576,12 @@ static void vgacon_init(struct vc_data *c, int init)
if (vga_512_chars) if (vga_512_chars)
c->vc_hi_font_mask = 0x0800; c->vc_hi_font_mask = 0x0800;
p = *c->vc_uni_pagedir_loc; p = *c->vc_uni_pagedir_loc;
if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir || if (c->vc_uni_pagedir_loc != &vgacon_uni_pagedir) {
!--c->vc_uni_pagedir_loc[1])
con_free_unimap(c); con_free_unimap(c);
c->vc_uni_pagedir_loc = vgacon_uni_pagedir; c->vc_uni_pagedir_loc = &vgacon_uni_pagedir;
vgacon_uni_pagedir[1]++; vgacon_refcount++;
if (!vgacon_uni_pagedir[0] && p) }
if (!vgacon_uni_pagedir && p)
con_set_default_unimap(c); con_set_default_unimap(c);
/* Only set the default if the user didn't deliberately override it */ /* 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,7 +598,7 @@ static void vgacon_deinit(struct vc_data *c)
vga_set_mem_top(c); vga_set_mem_top(c);
} }
if (!--vgacon_uni_pagedir[1]) if (!--vgacon_refcount)
con_free_unimap(c); con_free_unimap(c);
c->vc_uni_pagedir_loc = &c->vc_uni_pagedir; c->vc_uni_pagedir_loc = &c->vc_uni_pagedir;
con_set_default_unimap(c); con_set_default_unimap(c);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment