Skip to content

Commit 4497364

Browse files
peilin-yedanvet
authored andcommitted
parisc/sticore: Avoid hard-coding built-in font charcount
sti_select_fbfont() and sti_cook_fonts() are hard-coding the number of characters of our built-in fonts as 256. Recently, we included that information in our kernel font descriptor `struct font_desc`, so use `fbfont->charcount` instead of hard-coded values. Depends on patch "Fonts: Add charcount field to font_desc". Signed-off-by: Peilin Ye <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/037186fb50cf3d17bb7bc9482357635b9df6076e.1605169912.git.yepeilin.cs@gmail.com
1 parent 4ee5730 commit 4497364

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/video/console/sticore.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,15 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
506506
fbfont->width, fbfont->height, fbfont->name);
507507

508508
bpc = ((fbfont->width+7)/8) * fbfont->height;
509-
size = bpc * 256;
509+
size = bpc * fbfont->charcount;
510510
size += sizeof(struct sti_rom_font);
511511

512512
nf = kzalloc(size, STI_LOWMEM);
513513
if (!nf)
514514
return NULL;
515515

516516
nf->first_char = 0;
517-
nf->last_char = 255;
517+
nf->last_char = fbfont->charcount - 1;
518518
nf->width = fbfont->width;
519519
nf->height = fbfont->height;
520520
nf->font_type = STI_FONT_HPROMAN8;
@@ -525,7 +525,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
525525

526526
dest = nf;
527527
dest += sizeof(struct sti_rom_font);
528-
memcpy(dest, fbfont->data, bpc*256);
528+
memcpy(dest, fbfont->data, bpc * fbfont->charcount);
529529

530530
cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL);
531531
if (!cooked_font) {
@@ -660,7 +660,7 @@ static int sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
660660
void sti_font_convert_bytemode(struct sti_struct *sti, struct sti_cooked_font *f)
661661
{
662662
unsigned char *n, *p, *q;
663-
int size = f->raw->bytes_per_char * 256 + sizeof(struct sti_rom_font);
663+
int size = f->raw->bytes_per_char * (f->raw->last_char + 1) + sizeof(struct sti_rom_font);
664664
struct sti_rom_font *old_font;
665665

666666
if (sti->wordmode)

0 commit comments

Comments
 (0)