Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <yepeilin.cs@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/037186fb50cf3d17bb7bc9482357635b9df6076e.1605169912.git.yepeilin.cs@gmail.com

authored by

Peilin Ye and committed by
Daniel Vetter
4497364e 4ee57308

+4 -4
+4 -4
drivers/video/console/sticore.c
··· 506 506 fbfont->width, fbfont->height, fbfont->name); 507 507 508 508 bpc = ((fbfont->width+7)/8) * fbfont->height; 509 - size = bpc * 256; 509 + size = bpc * fbfont->charcount; 510 510 size += sizeof(struct sti_rom_font); 511 511 512 512 nf = kzalloc(size, STI_LOWMEM); ··· 514 514 return NULL; 515 515 516 516 nf->first_char = 0; 517 - nf->last_char = 255; 517 + nf->last_char = fbfont->charcount - 1; 518 518 nf->width = fbfont->width; 519 519 nf->height = fbfont->height; 520 520 nf->font_type = STI_FONT_HPROMAN8; ··· 525 525 526 526 dest = nf; 527 527 dest += sizeof(struct sti_rom_font); 528 - memcpy(dest, fbfont->data, bpc*256); 528 + memcpy(dest, fbfont->data, bpc * fbfont->charcount); 529 529 530 530 cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL); 531 531 if (!cooked_font) { ··· 660 660 void sti_font_convert_bytemode(struct sti_struct *sti, struct sti_cooked_font *f) 661 661 { 662 662 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); 664 664 struct sti_rom_font *old_font; 665 665 666 666 if (sti->wordmode)