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

Configure Feed

Select the types of activity you want to include in your feed.

vt: Calculate font-buffer size with vc_font_size()

In fbcon, fbcon_resize() computes the size of the font buffer from the
values stored in vc_font. Move these calculations to the dedicated helpers
vc_font_pitch() and vc_font_size().

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Thomas Zimmermann and committed by
Helge Deller
e370d84b 61912c60

+30 -7
+2 -7
drivers/video/fbdev/core/fbcon.c
··· 2037 2037 } 2038 2038 2039 2039 #define PITCH(w) (((w) + 7) >> 3) 2040 - #define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */ 2041 2040 2042 2041 static int fbcon_resize(struct vc_data *vc, unsigned int width, 2043 2042 unsigned int height, bool from_user) ··· 2048 2049 int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh; 2049 2050 2050 2051 if (p->userfont && FNTSIZE(vc->vc_font.data)) { 2051 - int size; 2052 - int pitch = PITCH(vc->vc_font.width); 2052 + unsigned int size = vc_font_size(&vc->vc_font); 2053 2053 2054 2054 /* 2055 2055 * If user font, ensure that a possible change to user font ··· 2057 2059 * charcount can change and cannot be used to determine the 2058 2060 * font data allocated size. 2059 2061 */ 2060 - if (pitch <= 0) 2061 - return -EINVAL; 2062 - size = CALC_FONTSZ(vc->vc_font.height, pitch, vc->vc_font.charcount); 2063 - if (size > FNTSIZE(vc->vc_font.data)) 2062 + if (!size || size > FNTSIZE(vc->vc_font.data)) 2064 2063 return -EINVAL; 2065 2064 } 2066 2065
+28
include/linux/console_struct.h
··· 83 83 const unsigned char *data; 84 84 }; 85 85 86 + /** 87 + * vc_font_pitch - Calculates the number of bytes between two adjacent scanlines 88 + * @font: The VC font 89 + * 90 + * Returns: 91 + * The number of bytes between two adjacent scanlines in the font data 92 + */ 93 + static inline unsigned int vc_font_pitch(const struct vc_font *font) 94 + { 95 + return DIV_ROUND_UP(font->width, 8); 96 + } 97 + 98 + /** 99 + * vc_font_size - Calculates the size of the font data in bytes 100 + * @font: The VC font 101 + * 102 + * vc_font_size() calculates the number of bytes of font data in the 103 + * font specified by @font. The function calculates the size from the 104 + * font parameters. 105 + * 106 + * Returns: 107 + * The size of the font data in bytes. 108 + */ 109 + static inline unsigned int vc_font_size(const struct vc_font *font) 110 + { 111 + return font->height * vc_font_pitch(font) * font->charcount; 112 + } 113 + 86 114 /* 87 115 * Example: vc_data of a console that was scrolled 3 lines down. 88 116 *