Skip to content

Commit b868070

Browse files
tdzardbiesheuvel
authored andcommitted
efi: earlycon: Reduce number of references to global screen_info
Replace usage of global screen_info with local pointers. This will later reduce churn when screen_info is being moved. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Richard Lyu <richard.lyu@suse.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent c7c7eb5 commit b868070

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

drivers/firmware/efi/earlycon.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ static void *efi_fb;
3232
*/
3333
static int __init efi_earlycon_remap_fb(void)
3434
{
35+
const struct screen_info *si = &screen_info;
36+
3537
/* bail if there is no bootconsole or it was unregistered already */
3638
if (!earlycon_console || !console_is_registered(earlycon_console))
3739
return 0;
3840

39-
efi_fb = memremap(fb_base, screen_info.lfb_size,
40-
fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
41+
efi_fb = memremap(fb_base, si->lfb_size, fb_wb ? MEMREMAP_WB : MEMREMAP_WC);
4142

4243
return efi_fb ? 0 : -ENOMEM;
4344
}
@@ -71,12 +72,12 @@ static __ref void efi_earlycon_unmap(void *addr, unsigned long len)
7172
early_memunmap(addr, len);
7273
}
7374

74-
static void efi_earlycon_clear_scanline(unsigned int y)
75+
static void efi_earlycon_clear_scanline(unsigned int y, const struct screen_info *si)
7576
{
7677
unsigned long *dst;
7778
u16 len;
7879

79-
len = screen_info.lfb_linelength;
80+
len = si->lfb_linelength;
8081
dst = efi_earlycon_map(y*len, len);
8182
if (!dst)
8283
return;
@@ -85,7 +86,7 @@ static void efi_earlycon_clear_scanline(unsigned int y)
8586
efi_earlycon_unmap(dst, len);
8687
}
8788

88-
static void efi_earlycon_scroll_up(void)
89+
static void efi_earlycon_scroll_up(const struct screen_info *si)
8990
{
9091
unsigned long *dst, *src;
9192
u16 maxlen = 0;
@@ -99,8 +100,8 @@ static void efi_earlycon_scroll_up(void)
99100
}
100101
maxlen *= 4;
101102

102-
len = screen_info.lfb_linelength;
103-
height = screen_info.lfb_height;
103+
len = si->lfb_linelength;
104+
height = si->lfb_height;
104105

105106
for (i = 0; i < height - font->height; i++) {
106107
dst = efi_earlycon_map(i*len, len);
@@ -120,7 +121,8 @@ static void efi_earlycon_scroll_up(void)
120121
}
121122
}
122123

123-
static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
124+
static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h,
125+
const struct screen_info *si)
124126
{
125127
const u32 color_black = 0x00000000;
126128
const u32 color_white = 0x00ffffff;
@@ -145,13 +147,12 @@ static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
145147
static void
146148
efi_earlycon_write(struct console *con, const char *str, unsigned int num)
147149
{
148-
struct screen_info *si;
150+
const struct screen_info *si = &screen_info;
149151
u32 cur_efi_x = efi_x;
150152
unsigned int len;
151153
const char *s;
152154
void *dst;
153155

154-
si = &screen_info;
155156
len = si->lfb_linelength;
156157

157158
while (num) {
@@ -174,7 +175,7 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
174175
x = efi_x;
175176

176177
while (n-- > 0) {
177-
efi_earlycon_write_char(dst + x*4, *s, h);
178+
efi_earlycon_write_char(dst + x * 4, *s, h, si);
178179
x += font->width;
179180
s++;
180181
}
@@ -207,10 +208,10 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
207208
cur_line_y = (cur_line_y + 1) % max_line_y;
208209

209210
efi_y -= font->height;
210-
efi_earlycon_scroll_up();
211+
efi_earlycon_scroll_up(si);
211212

212213
for (i = 0; i < font->height; i++)
213-
efi_earlycon_clear_scanline(efi_y + i);
214+
efi_earlycon_clear_scanline(efi_y + i, si);
214215
}
215216
}
216217
}
@@ -226,22 +227,21 @@ void __init efi_earlycon_reprobe(void)
226227
static int __init efi_earlycon_setup(struct earlycon_device *device,
227228
const char *opt)
228229
{
229-
struct screen_info *si;
230+
const struct screen_info *si = &screen_info;
230231
u16 xres, yres;
231232
u32 i;
232233

233234
fb_wb = opt && !strcmp(opt, "ram");
234235

235-
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) {
236+
if (si->orig_video_isVGA != VIDEO_TYPE_EFI) {
236237
fb_probed = true;
237238
return -ENODEV;
238239
}
239240

240-
fb_base = screen_info.lfb_base;
241-
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
242-
fb_base |= (u64)screen_info.ext_lfb_base << 32;
241+
fb_base = si->lfb_base;
242+
if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
243+
fb_base |= (u64)si->ext_lfb_base << 32;
243244

244-
si = &screen_info;
245245
xres = si->lfb_width;
246246
yres = si->lfb_height;
247247

@@ -266,7 +266,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
266266

267267
efi_y -= font->height;
268268
for (i = 0; i < (yres - efi_y) / font->height; i++)
269-
efi_earlycon_scroll_up();
269+
efi_earlycon_scroll_up(si);
270270

271271
device->con->write = efi_earlycon_write;
272272
earlycon_console = device->con;

0 commit comments

Comments
 (0)