]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
parisc/sticore: Avoid hard-coding built-in font charcount
authorPeilin Ye <yepeilin.cs@gmail.com>
Thu, 12 Nov 2020 12:14:21 +0000 (07:14 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:12:00 +0000 (13:12 +0100)
commit 4497364e5f61f9e8d4a6252bc6deb9597d68bbac upstream.

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
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/video/console/sticore.c

index 68fb531f245a564949ec33863b72a286e06543c1..19fd3389946d95339a8e9c7f2e0cd4ef248c7e91 100644 (file)
@@ -507,7 +507,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
                        fbfont->width, fbfont->height, fbfont->name);
                        
        bpc = ((fbfont->width+7)/8) * fbfont->height; 
-       size = bpc * 256;
+       size = bpc * fbfont->charcount;
        size += sizeof(struct sti_rom_font);
 
        nf = kzalloc(size, STI_LOWMEM);
@@ -515,7 +515,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
                return NULL;
 
        nf->first_char = 0;
-       nf->last_char = 255;
+       nf->last_char = fbfont->charcount - 1;
        nf->width = fbfont->width;
        nf->height = fbfont->height;
        nf->font_type = STI_FONT_HPROMAN8;
@@ -526,7 +526,7 @@ sti_select_fbfont(struct sti_cooked_rom *cooked_rom, const char *fbfont_name)
 
        dest = nf;
        dest += sizeof(struct sti_rom_font);
-       memcpy(dest, fbfont->data, bpc*256);
+       memcpy(dest, fbfont->data, bpc * fbfont->charcount);
 
        cooked_font = kzalloc(sizeof(*cooked_font), GFP_KERNEL);
        if (!cooked_font) {
@@ -661,7 +661,7 @@ static int sti_cook_fonts(struct sti_cooked_rom *cooked_rom,
 void sti_font_convert_bytemode(struct sti_struct *sti, struct sti_cooked_font *f)
 {
        unsigned char *n, *p, *q;
-       int size = f->raw->bytes_per_char * 256 + sizeof(struct sti_rom_font);
+       int size = f->raw->bytes_per_char * (f->raw->last_char + 1) + sizeof(struct sti_rom_font);
        struct sti_rom_font *old_font;
 
        if (sti->wordmode)