From patchwork Thu Nov 12 12:04:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11899873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6B1E14C0 for ; Thu, 12 Nov 2020 12:05:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8469E20872 for ; Thu, 12 Nov 2020 12:05:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tWZZLSpZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727790AbgKLMFT (ORCPT ); Thu, 12 Nov 2020 07:05:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726969AbgKLMFQ (ORCPT ); Thu, 12 Nov 2020 07:05:16 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363D5C0613D1; Thu, 12 Nov 2020 04:05:16 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id i13so3992489pgm.9; Thu, 12 Nov 2020 04:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IZQaNtNkLL6z6ZbtohWqKAcM+GdB+jm2XeErfe9vHvk=; b=tWZZLSpZQp22wCUD9a5oZxqbpelF7THomnGgPYP9PNTyxbAVSr2agCxI5OniPq2g/r nf0TcAHxo3fIWXJa8O3yMqN2ED6fxzXQso9mKvKJYl/vBT2n5S2PvEGtxG3t0j/DxoGA NwbXNERV6wV9E8oxhZNi5NSYn6BVRl+0Rw7j6iHVtWXEnVXIqEiySm3yYyb2j9C1B/On k39IE3CQkFcuD4rvK77NtBJAMo3Px1OMJ2NI/e23UFzOgPK4xQY495FJ79OUycHZfQgR aRVTK4R9TwBAmdh4ulPFceB0/1cJpm3N47vf/y4qvSBZAaTf2Yqy4pj4fiA6356S5ofz wQuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IZQaNtNkLL6z6ZbtohWqKAcM+GdB+jm2XeErfe9vHvk=; b=QKRzFQNgEM8DIBlPUhHdiNsy/zWQL2Lus+aLw9iF8DTjbLkUd73oMewO5vLVHUJ3c0 GoglmCtr5Mfkn3s2R3B7iNjqUTVrbAjkPkVLfwmUK86C96UV15dBwIfc1ZudiQfNfznU abOlH/lH50c4THB70hJc0N1xxQvlJOv62qIDz7oFfyoq5NEA0t5b2J2CvO5iZBPtwdXR WxdexpVgVG1i3M2kQIN1VgMjPS4RKIhYWFsJt48zZlEBtxJwebexRn0c0O1ewqjcESTB 7IAnn0SoCQ2vEgKoBXeENvaFP4Ir1rAIgJJ7p+SkjfXjpyvawzKbsmxvvLM+TxpzdX5s vlZQ== X-Gm-Message-State: AOAM530/BHLnXpeljgdIAs1O5inoYPq6j0ztYrQRNwz7yDu7rZ+YNT/J aFPAlp9788RXOgyFImsPIw== X-Google-Smtp-Source: ABdhPJzO1hDeZ2IhKJ6bqNEiYkz8GU6RttBVRGOqDMF23KFVlKIirfFc4QCLUbOzesItxvr8eD/yrg== X-Received: by 2002:a62:1b02:0:b029:18a:b052:deb1 with SMTP id b2-20020a621b020000b029018ab052deb1mr28203408pfb.32.1605182715659; Thu, 12 Nov 2020 04:05:15 -0800 (PST) Received: from localhost.localdomain ([221.124.243.27]) by smtp.gmail.com with ESMTPSA id i7sm6567928pjj.20.2020.11.12.04.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 04:05:14 -0800 (PST) From: Peilin Ye To: Daniel Vetter Cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Winischhofer , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Peilin Ye Subject: [PATCH 1/5] console: Delete unused con_font_copy() callback implementations Date: Thu, 12 Nov 2020 07:04:03 -0500 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Recently in commit 3c4e0dff2095 ("vt: Disable KD_FONT_OP_COPY") we disabled the KD_FONT_OP_COPY ioctl() option. Delete all the con_font_copy() callbacks, since we no longer use them. Mark KD_FONT_OP_COPY as "obsolete" in include/uapi/linux/kd.h, just like what we have done for PPPIOCDETACH in commit af8d3c7c001a ("ppp: remove the PPPIOCDETACH ioctl"). Signed-off-by: Peilin Ye --- drivers/usb/misc/sisusbvga/sisusb_con.c | 6 ------ drivers/video/console/dummycon.c | 6 ------ drivers/video/fbdev/core/fbcon.c | 11 ----------- include/linux/console.h | 1 - include/uapi/linux/kd.h | 2 +- 5 files changed, 1 insertion(+), 25 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index c63e545fb105..fd9954381fbf 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c @@ -1358,11 +1358,6 @@ static int sisusbdummycon_font_default(struct vc_data *vc, return 0; } -static int sisusbdummycon_font_copy(struct vc_data *vc, int con) -{ - return 0; -} - static const struct consw sisusb_dummy_con = { .owner = THIS_MODULE, .con_startup = sisusbdummycon_startup, @@ -1377,7 +1372,6 @@ static const struct consw sisusb_dummy_con = { .con_blank = sisusbdummycon_blank, .con_font_set = sisusbdummycon_font_set, .con_font_default = sisusbdummycon_font_default, - .con_font_copy = sisusbdummycon_font_copy, }; int diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 2a0d0bda7faa..ab3df752fb57 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -136,11 +136,6 @@ static int dummycon_font_default(struct vc_data *vc, return 0; } -static int dummycon_font_copy(struct vc_data *vc, int con) -{ - return 0; -} - /* * The console `switch' structure for the dummy console * @@ -161,6 +156,5 @@ const struct consw dummy_con = { .con_blank = dummycon_blank, .con_font_set = dummycon_font_set, .con_font_default = dummycon_font_default, - .con_font_copy = dummycon_font_copy, }; EXPORT_SYMBOL_GPL(dummy_con); diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index cef437817b0d..26d1b0916692 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2451,16 +2451,6 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, return 0; } -static int fbcon_copy_font(struct vc_data *vc, int con) -{ - struct fbcon_display *od = &fb_display[con]; - struct console_font *f = &vc->vc_font; - - if (od->fontdata == f->data) - return 0; /* already the same font... */ - return fbcon_do_set_font(vc, f->width, f->height, od->fontdata, od->userfont); -} - /* * User asked to set font; we are guaranteed that * a) width and height are in range 1..32 @@ -3111,7 +3101,6 @@ static const struct consw fb_con = { .con_font_set = fbcon_set_font, .con_font_get = fbcon_get_font, .con_font_default = fbcon_set_def_font, - .con_font_copy = fbcon_copy_font, .con_set_palette = fbcon_set_palette, .con_invert_region = fbcon_invert_region, .con_screen_pos = fbcon_screen_pos, diff --git a/include/linux/console.h b/include/linux/console.h index 4b1e26c4cb42..20874db50bc8 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -62,7 +62,6 @@ struct consw { int (*con_font_get)(struct vc_data *vc, struct console_font *font); int (*con_font_default)(struct vc_data *vc, struct console_font *font, char *name); - int (*con_font_copy)(struct vc_data *vc, int con); int (*con_resize)(struct vc_data *vc, unsigned int width, unsigned int height, unsigned int user); void (*con_set_palette)(struct vc_data *vc, diff --git a/include/uapi/linux/kd.h b/include/uapi/linux/kd.h index 4616b31f84da..ee929ece4112 100644 --- a/include/uapi/linux/kd.h +++ b/include/uapi/linux/kd.h @@ -173,7 +173,7 @@ struct console_font { #define KD_FONT_OP_SET 0 /* Set font */ #define KD_FONT_OP_GET 1 /* Get font */ #define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */ -#define KD_FONT_OP_COPY 3 /* Copy from another console */ +#define KD_FONT_OP_COPY 3 /* Obsolete, do not use */ #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */ From patchwork Thu Nov 12 12:11:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11899879 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1B9F697 for ; Thu, 12 Nov 2020 12:11:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9292B207BB for ; Thu, 12 Nov 2020 12:11:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nfGWH+sC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727934AbgKLMLw (ORCPT ); Thu, 12 Nov 2020 07:11:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgKLMLw (ORCPT ); Thu, 12 Nov 2020 07:11:52 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DEC8C0613D1; Thu, 12 Nov 2020 04:11:52 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id c66so4364961pfa.4; Thu, 12 Nov 2020 04:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t1DdLgTC9wfaj9IQp94XVXE/ol9y5Kusx3kBt32JG7w=; b=nfGWH+sC/kJrBlznTemQAIuBYZQD2xNWxlJEtlggRHen6AMLz+O/MUAXtwEGzKvuZ/ bsS3SrCgqY+YgV9+IQFoE66cWTsqf59EVv7MAXIMcyCZLQBi3ZYrdH0UBRMuLlUf2yj9 b3zk/VlfZuKV5h+JRk2sbI5YCSK/eXZQe9SLBqml5q6VbrP+Hu37EXSklURgk0RJXkCL zaFuF/yPmrcY4R9Nl3tfQb6E0kpPJsUC1scb2nkDY4XAILjjEVTQ+IskKOpGAVM/tKzP a9OclLMKkoky6+eolkG9m1qHdhsY+dM5SBB4tu2ODyD6qKMArQFDJ5Rlnvj+QOkG6IN7 pMog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t1DdLgTC9wfaj9IQp94XVXE/ol9y5Kusx3kBt32JG7w=; b=OU69d8bAqyK+I/4tEJJRNMxpny5ha5Mp92v90p4TA1RjIjEfRUh2WUD2T/EEmKLxr+ 51qdN6OVJmdxvlvJvaz+CUCHeOgrPKsrYDqBSejaMfoTMfp3ZAwQZqL7DkJaECc5hI2R eDxhwwpva/noLLFIz7kM1y+2jYusdYyx/2w33qgi7fZJRnYqjd7W+eLNzYuYDsZivdDI t+EiQ8pyTj+OEpmnIAs4i+oQMNC7kvikDuKw5nyiXI9THQASysmq2laryLGQj58j2K98 rsVgD60/dWFXuWZOXHnOenXIJSB/320N2tJTUJf3HulvcmHc+KoebLHf8V8/ayXIHlKc m7uA== X-Gm-Message-State: AOAM533Hd0AzWh4oGcKayoPs7LEI1JvkkVpQHZ5gZsOE4Jdk4HM7jwBd 4Q8gGOl8Hf3TxG348n6LxVmouXuF+u8Dteo= X-Google-Smtp-Source: ABdhPJzoAKiGQyUiVJYAYxSHzoiJpwlzyy5z+eeSeCMFXBPBeQw15GAuIH4UK25wWxOwLWRnusSo1g== X-Received: by 2002:a17:90a:4295:: with SMTP id p21mr9377058pjg.217.1605183112075; Thu, 12 Nov 2020 04:11:52 -0800 (PST) Received: from localhost.localdomain ([221.124.243.27]) by smtp.gmail.com with ESMTPSA id v23sm6150243pfn.141.2020.11.12.04.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 04:11:51 -0800 (PST) From: Peilin Ye To: Daniel Vetter Cc: Greg Kroah-Hartman , Jiri Slaby , Thomas Winischhofer , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Peilin Ye Subject: [PATCH v3 2/5] console: Delete dummy con_font_set() and con_font_default() callback implementations Date: Thu, 12 Nov 2020 07:11:20 -0500 Message-Id: <9952c7538d2a32bb1a82af323be482e7afb3dedf.1605169912.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org .con_font_set and .con_font_default callbacks should not pass `struct console_font *` as a parameter, since `struct console_font` is a UAPI structure. We are trying to let them use our new kernel font descriptor, `struct font_desc` instead. To make that work slightly easier, first delete all of their no-op implementations used by dummy consoles. This will make KD_FONT_OP_SET and KD_FONT_OP_SET_DEFAULT ioctl() requests on dummy consoles start to fail and return `-ENOSYS`, which is intended, since no user should ever expect such operations to succeed on dummy consoles. Suggested-by: Daniel Vetter Signed-off-by: Peilin Ye Reviewed-by: Greg Kroah-Hartman --- v2: https://lore.kernel.org/lkml/c5563eeea36aae7bd72ea2e985bc610d585ece40.1604306433.git.yepeilin.cs@gmail.com/ Strictly speaking this is different from v2 (see changelog), but it really shouldn't matter, so I'm keeping Greg's "Reviewed-by:". Changes in v3: - Improve commit message. (Jiri) - Do not delete con_font_copy() callbacks, since they have been deleted in patch "console: Delete unused con_font_copy() callback implementations". Change in v2: - Do not Cc: stable. drivers/usb/misc/sisusbvga/sisusb_con.c | 15 --------------- drivers/video/console/dummycon.c | 14 -------------- 2 files changed, 29 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index fd9954381fbf..dfa0d5ce6012 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c @@ -1345,19 +1345,6 @@ static int sisusbdummycon_blank(struct vc_data *vc, int blank, int mode_switch) return 0; } -static int sisusbdummycon_font_set(struct vc_data *vc, - struct console_font *font, - unsigned int flags) -{ - return 0; -} - -static int sisusbdummycon_font_default(struct vc_data *vc, - struct console_font *font, char *name) -{ - return 0; -} - static const struct consw sisusb_dummy_con = { .owner = THIS_MODULE, .con_startup = sisusbdummycon_startup, @@ -1370,8 +1357,6 @@ static const struct consw sisusb_dummy_con = { .con_scroll = sisusbdummycon_scroll, .con_switch = sisusbdummycon_switch, .con_blank = sisusbdummycon_blank, - .con_font_set = sisusbdummycon_font_set, - .con_font_default = sisusbdummycon_font_default, }; int diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index ab3df752fb57..f1711b2f9ff0 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -124,18 +124,6 @@ static int dummycon_switch(struct vc_data *vc) return 0; } -static int dummycon_font_set(struct vc_data *vc, struct console_font *font, - unsigned int flags) -{ - return 0; -} - -static int dummycon_font_default(struct vc_data *vc, - struct console_font *font, char *name) -{ - return 0; -} - /* * The console `switch' structure for the dummy console * @@ -154,7 +142,5 @@ const struct consw dummy_con = { .con_scroll = dummycon_scroll, .con_switch = dummycon_switch, .con_blank = dummycon_blank, - .con_font_set = dummycon_font_set, - .con_font_default = dummycon_font_default, }; EXPORT_SYMBOL_GPL(dummy_con); From patchwork Thu Nov 12 12:13:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11899889 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB87015E6 for ; Thu, 12 Nov 2020 12:14:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B681422227 for ; Thu, 12 Nov 2020 12:14:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LiCAKIXo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbgKLMOL (ORCPT ); Thu, 12 Nov 2020 07:14:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbgKLMOL (ORCPT ); Thu, 12 Nov 2020 07:14:11 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5840C0613D1; Thu, 12 Nov 2020 04:14:09 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id g11so2668511pll.13; Thu, 12 Nov 2020 04:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qI9FK/WV51uzQ+5U+ONFL1fdnGeKCbg3gawqygIR1rw=; b=LiCAKIXoQ/iIwwnWehfp70HaCZr7hqUs5nQurinaasuuQkf5shQk2yCWppH8DeypON FzjE8L9P9rmFDKm0sxcmuuMRBV6goxWjSJMk4AXeNaCAjqGl1MYPH81SgieJGYWE336i iLgXInHsw+34YgQ8Zqr/BlP5QQ3USAvuNR32SJgYj1dIWft9aXiddAZ+6VPl+CZEPk3g ZfUochzcS6e4jOYFecwZ0z3c+q/WgoiynQA7Ooo8DXSXjnPXcHducT25lhexyv9jRv6o zObOThTte/W3XhNeOXUgFxealnGRNjSg/1Q5DCjA/kK14X1rWf9WlkUdo4SRKOUq44KP eNAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qI9FK/WV51uzQ+5U+ONFL1fdnGeKCbg3gawqygIR1rw=; b=GDBbq095NKyZZ97jwtZKg+AwApRkF22GjJklPGBrWdtAnFwLFzxKrCioDa6gNSOtDp h2okTHXVwvcRlqYWdAm9VXIolPky2Ma9w80wSIa4hGn/knlUSamkN03/dzggg/K/OGlW dIk7WKGlM/hLjZ1v2PV0dZmw8yQvxk3UZ6Cp+BfOvfQf83rBOn7fzQ6C0YG4DcSPiaE/ nF+6k6v0dRVJCx9dVE8mPd4MFk7jYTFxj8UOpaB/gpWcEK3sGs6RRdCRJMz04+Qxm8RS rzrIb50hD0qaiXQ2fteVOgFlF8+DpeGB5HrDx7360tm3Wu3gRiJ98XU5rGj9QutrfoGz Y3pw== X-Gm-Message-State: AOAM5339aPwuccgrJi5MD3INvpIhITPpzwvsvoxXgMJrO9OtZei+3Fy7 pC0NihGjdOmNJggzxZa3sw== X-Google-Smtp-Source: ABdhPJzxKGVRreaxt+hicCEYOLKxX4XkRjA1eKqizBS4+nlzy24IRoAfLir/N/deiS8Yr2k49PvPyQ== X-Received: by 2002:a17:902:7c16:b029:d8:ac5d:3e9c with SMTP id x22-20020a1709027c16b02900d8ac5d3e9cmr12467169pll.68.1605183247901; Thu, 12 Nov 2020 04:14:07 -0800 (PST) Received: from localhost.localdomain ([221.124.243.27]) by smtp.gmail.com with ESMTPSA id a20sm6062637pff.118.2020.11.12.04.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 04:14:07 -0800 (PST) From: Peilin Ye To: Daniel Vetter Cc: Greg Kroah-Hartman , "James E . J . Bottomley" , Helge Deller , Jiri Slaby , Tetsuo Handa , Bartlomiej Zolnierkiewicz , linux-parisc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Peilin Ye Subject: [PATCH v3 3/5] Fonts: Add charcount field to font_desc Date: Thu, 12 Nov 2020 07:13:34 -0500 Message-Id: <65952296d1d9486093bd955d1536f7dcd11112c6.1605169912.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Subsystems are hard-coding the number of characters of our built-in fonts as 256. Include that information in our kernel font descriptor, `struct font_desc`. Signed-off-by: Peilin Ye Reviewed-by: Daniel Vetter --- v2: https://lore.kernel.org/lkml/20201028060533.1206307-1-yepeilin.cs@gmail.com/ Change in v3: - Rebase onto linux-next. Change in v2: - Rebase onto 5.10-rc1. include/linux/font.h | 1 + lib/fonts/font_10x18.c | 1 + lib/fonts/font_6x10.c | 1 + lib/fonts/font_6x11.c | 1 + lib/fonts/font_6x8.c | 1 + lib/fonts/font_7x14.c | 1 + lib/fonts/font_8x16.c | 1 + lib/fonts/font_8x8.c | 1 + lib/fonts/font_acorn_8x8.c | 1 + lib/fonts/font_mini_4x6.c | 1 + lib/fonts/font_pearl_8x8.c | 1 + lib/fonts/font_sun12x22.c | 1 + lib/fonts/font_sun8x16.c | 1 + lib/fonts/font_ter16x32.c | 1 + 14 files changed, 14 insertions(+) diff --git a/include/linux/font.h b/include/linux/font.h index 4f50d736ea72..abf1442ce719 100644 --- a/include/linux/font.h +++ b/include/linux/font.h @@ -17,6 +17,7 @@ struct font_desc { int idx; const char *name; unsigned int width, height; + unsigned int charcount; const void *data; int pref; }; diff --git a/lib/fonts/font_10x18.c b/lib/fonts/font_10x18.c index e02f9df24d1e..5d940db626e7 100644 --- a/lib/fonts/font_10x18.c +++ b/lib/fonts/font_10x18.c @@ -5137,6 +5137,7 @@ const struct font_desc font_10x18 = { .name = "10x18", .width = 10, .height = 18, + .charcount = 256, .data = fontdata_10x18.data, #ifdef __sparc__ .pref = 5, diff --git a/lib/fonts/font_6x10.c b/lib/fonts/font_6x10.c index 6e3c4b7691c8..e65df019e0d2 100644 --- a/lib/fonts/font_6x10.c +++ b/lib/fonts/font_6x10.c @@ -3083,6 +3083,7 @@ const struct font_desc font_6x10 = { .name = "6x10", .width = 6, .height = 10, + .charcount = 256, .data = fontdata_6x10.data, .pref = 0, }; diff --git a/lib/fonts/font_6x11.c b/lib/fonts/font_6x11.c index 2d22a24e816f..bd76b3f6b635 100644 --- a/lib/fonts/font_6x11.c +++ b/lib/fonts/font_6x11.c @@ -3346,6 +3346,7 @@ const struct font_desc font_vga_6x11 = { .name = "ProFont6x11", .width = 6, .height = 11, + .charcount = 256, .data = fontdata_6x11.data, /* Try avoiding this font if possible unless on MAC */ .pref = -2000, diff --git a/lib/fonts/font_6x8.c b/lib/fonts/font_6x8.c index e7442a0d183d..06ace7792521 100644 --- a/lib/fonts/font_6x8.c +++ b/lib/fonts/font_6x8.c @@ -2571,6 +2571,7 @@ const struct font_desc font_6x8 = { .name = "6x8", .width = 6, .height = 8, + .charcount = 256, .data = fontdata_6x8.data, .pref = 0, }; diff --git a/lib/fonts/font_7x14.c b/lib/fonts/font_7x14.c index 9cc7ae2e03f7..a2f561c9fa04 100644 --- a/lib/fonts/font_7x14.c +++ b/lib/fonts/font_7x14.c @@ -4113,6 +4113,7 @@ const struct font_desc font_7x14 = { .name = "7x14", .width = 7, .height = 14, + .charcount = 256, .data = fontdata_7x14.data, .pref = 0, }; diff --git a/lib/fonts/font_8x16.c b/lib/fonts/font_8x16.c index bab25dc59e8d..06ae14088514 100644 --- a/lib/fonts/font_8x16.c +++ b/lib/fonts/font_8x16.c @@ -4627,6 +4627,7 @@ const struct font_desc font_vga_8x16 = { .name = "VGA8x16", .width = 8, .height = 16, + .charcount = 256, .data = fontdata_8x16.data, .pref = 0, }; diff --git a/lib/fonts/font_8x8.c b/lib/fonts/font_8x8.c index 109d0572368f..69570b8c31af 100644 --- a/lib/fonts/font_8x8.c +++ b/lib/fonts/font_8x8.c @@ -2578,6 +2578,7 @@ const struct font_desc font_vga_8x8 = { .name = "VGA8x8", .width = 8, .height = 8, + .charcount = 256, .data = fontdata_8x8.data, .pref = 0, }; diff --git a/lib/fonts/font_acorn_8x8.c b/lib/fonts/font_acorn_8x8.c index fb395f0d4031..18755c33d249 100644 --- a/lib/fonts/font_acorn_8x8.c +++ b/lib/fonts/font_acorn_8x8.c @@ -270,6 +270,7 @@ const struct font_desc font_acorn_8x8 = { .name = "Acorn8x8", .width = 8, .height = 8, + .charcount = 256, .data = acorndata_8x8.data, #ifdef CONFIG_ARCH_ACORN .pref = 20, diff --git a/lib/fonts/font_mini_4x6.c b/lib/fonts/font_mini_4x6.c index 592774a90917..8d39fd447952 100644 --- a/lib/fonts/font_mini_4x6.c +++ b/lib/fonts/font_mini_4x6.c @@ -2152,6 +2152,7 @@ const struct font_desc font_mini_4x6 = { .name = "MINI4x6", .width = 4, .height = 6, + .charcount = 256, .data = fontdata_mini_4x6.data, .pref = 3, }; diff --git a/lib/fonts/font_pearl_8x8.c b/lib/fonts/font_pearl_8x8.c index a6f95ebce950..b1678ed0017c 100644 --- a/lib/fonts/font_pearl_8x8.c +++ b/lib/fonts/font_pearl_8x8.c @@ -2582,6 +2582,7 @@ const struct font_desc font_pearl_8x8 = { .name = "PEARL8x8", .width = 8, .height = 8, + .charcount = 256, .data = fontdata_pearl8x8.data, .pref = 2, }; diff --git a/lib/fonts/font_sun12x22.c b/lib/fonts/font_sun12x22.c index a5b65bd49604..91daf5ab8b6b 100644 --- a/lib/fonts/font_sun12x22.c +++ b/lib/fonts/font_sun12x22.c @@ -6156,6 +6156,7 @@ const struct font_desc font_sun_12x22 = { .name = "SUN12x22", .width = 12, .height = 22, + .charcount = 256, .data = fontdata_sun12x22.data, #ifdef __sparc__ .pref = 5, diff --git a/lib/fonts/font_sun8x16.c b/lib/fonts/font_sun8x16.c index e577e76a6a7c..81bb4eeae04e 100644 --- a/lib/fonts/font_sun8x16.c +++ b/lib/fonts/font_sun8x16.c @@ -268,6 +268,7 @@ const struct font_desc font_sun_8x16 = { .name = "SUN8x16", .width = 8, .height = 16, + .charcount = 256, .data = fontdata_sun8x16.data, #ifdef __sparc__ .pref = 10, diff --git a/lib/fonts/font_ter16x32.c b/lib/fonts/font_ter16x32.c index f7c3abb6b99e..1955d624177c 100644 --- a/lib/fonts/font_ter16x32.c +++ b/lib/fonts/font_ter16x32.c @@ -2062,6 +2062,7 @@ const struct font_desc font_ter_16x32 = { .name = "TER16x32", .width = 16, .height = 32, + .charcount = 256, .data = fontdata_ter16x32.data, #ifdef __sparc__ .pref = 5, From patchwork Thu Nov 12 12:14:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11899897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E021615E6 for ; Thu, 12 Nov 2020 12:15:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B48292222C for ; Thu, 12 Nov 2020 12:15:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VAmHGapX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727942AbgKLMO6 (ORCPT ); Thu, 12 Nov 2020 07:14:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbgKLMO6 (ORCPT ); Thu, 12 Nov 2020 07:14:58 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B722C0613D1; Thu, 12 Nov 2020 04:14:58 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id f27so4039369pgl.1; Thu, 12 Nov 2020 04:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ji+otFl/WkNW1j02CrZ/ivgsssCDblUPej71NkGlu3o=; b=VAmHGapXMocqcjRZS1SlTPSyIL91R0FKwosP3HJ0EzX8ZCW0Vapjr+mTSHwWi4H2Hx nmYgcEsRbatUB9qIPOrObI7lrBsImUMUhbDgb2sSa8pBgzMK7qC4jlKXSgfdpv2p9Vvt CaLjIjo84AOJyk4jquop1y0edQUm4GdzLOz+QckbMb2Gw8mK9E/HJ6bOzPJyjTlXeE6H 3yd7+KsSn8tw56tLESaCPsBWWOSTwuwfQljPyzY3QCpASQZzE423pBVzFQZNI/dpcprB 0XPgfxSNR8KWyrdssDM2HF03+n7wSmJDrGy8M/bPuXQLPPBIID8ctqRlOCMQJoXYrxP6 8hpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ji+otFl/WkNW1j02CrZ/ivgsssCDblUPej71NkGlu3o=; b=V5y0w1lIlF7FvblJTCAFcxSTF7lOGEoziWCna/BokjD+l8Kw7EjNoLQGbEB/9VQijz Yw0XCjQ+CKYWCd82HK0qlLJ7f6woIlie27JhKiDlE7Q+hcl+0B7gSw4/u6yOGRDKGCsX bu9hioYJs6muvsdjpw1kz4c+lPGoVm8gdCpOJUC8q22DvhEkW+mpryQZNHwvgE2FTCHq huioRbktgt5J1eHRt4cCaSEYL9Skdpvl6DFC+Ms79fmybX/tg6LCvqhcqA/a9Uy8LDf2 ERSjdxNTF/MmNYSRFwjdr7TM2SikqiOheUI8GQag2Kq/3g2dBHl48fJ5/U90Ohj276it UZHQ== X-Gm-Message-State: AOAM530JVG7gwYj6acpyaBcd+y/LciZWdlx7eABqjcVe8cOF2AmphHrf MT4+4TcAZdilpNFheuRB22r8U56f3SMNa3g= X-Google-Smtp-Source: ABdhPJyxx19WWls1VMlKeNllLZ/re1JCrpPUArBW0x9CN4NVZKyR+t+YJw14Unb5U6Oq00zSvevmAg== X-Received: by 2002:a17:90a:4a0f:: with SMTP id e15mr8953328pjh.182.1605183297641; Thu, 12 Nov 2020 04:14:57 -0800 (PST) Received: from localhost.localdomain ([221.124.243.27]) by smtp.gmail.com with ESMTPSA id d145sm6785736pfd.136.2020.11.12.04.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 04:14:57 -0800 (PST) From: Peilin Ye To: Daniel Vetter Cc: Greg Kroah-Hartman , "James E . J . Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Peilin Ye Subject: [PATCH v3 4/5] parisc/sticore: Avoid hard-coding built-in font charcount Date: Thu, 12 Nov 2020 07:14:21 -0500 Message-Id: <037186fb50cf3d17bb7bc9482357635b9df6076e.1605169912.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 Reviewed-by: Daniel Vetter --- v2: https://lore.kernel.org/lkml/c38042bbf5c9777c84900d56c09f3c156b32af48.1603788512.git.yepeilin.cs@gmail.com/ Changes since v1: - Slightly improved commit message. - Rebased onto linux-next. drivers/video/console/sticore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c index d1bb5915082b..f869b723494f 100644 --- a/drivers/video/console/sticore.c +++ b/drivers/video/console/sticore.c @@ -506,7 +506,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); @@ -514,7 +514,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; @@ -525,7 +525,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) { @@ -660,7 +660,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) From patchwork Thu Nov 12 12:15:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11899901 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE7D6697 for ; Thu, 12 Nov 2020 12:16:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F2A62222C for ; Thu, 12 Nov 2020 12:16:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AIARY+rF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbgKLMQO (ORCPT ); Thu, 12 Nov 2020 07:16:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbgKLMQN (ORCPT ); Thu, 12 Nov 2020 07:16:13 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAC7BC0613D1; Thu, 12 Nov 2020 04:16:13 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id a18so4371010pfl.3; Thu, 12 Nov 2020 04:16:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MPQ4TOsr/Zn4JKDK9zKQyfsUBs8Lur4NckSKEQ2T9Us=; b=AIARY+rFNzoLDqv93OqHzkS3m5skWiZGsLcPDoeOhAIrk2Kl22iYeHrl/Oa09tIDtR 24/iQTLmYLUIPorErg3lQSWvU+rC4SzoT+eXsE8ojD5iYm+T7JL7qArjgOdv5GHv4Q/K bCLMuo2dZWtlzwqWSMh57mRq0Ducxtws73JzRsmBqJr8lASHkbe4TQy5XEXxk6yyNGpL asqBmp18Z4VhKwOSK6N+p2fHn/EirjPMLV8yhtQajS/ehA584kkbFNVPdfOC8DJumzUV VectLo7bvWuaNMxNCyKv7sG0VunXSsNTiL7BoK13xjtz7Z9n+qq+IhJyRhF9lzplom1y Qczw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MPQ4TOsr/Zn4JKDK9zKQyfsUBs8Lur4NckSKEQ2T9Us=; b=LrfsBKK7myBdtYLfiWTEf7K/vWl4iSI0QeMW6LG+K+TYnEd4SWNMHu34utrJAri4UT YK1vmSEs1PojmyZPvI5Hnkh4JEwcGHQmA93C1SPHfogLSOicJY7bUJ1IsdFbjWIDbOkv RpjVD4LsbrzkoFDsEQU0iyVzPoRWuGnQdSYVhYENznvBkLaS5s3BWtCeYkrtYyLKjvYi Bmh160QMl5LHc0f7d2IW16eKn5YhfL7+lpJLA9vfMKgNSC+7UZn1IIHpBFFxkV81nClZ fKuV4Bsqh7avInvnQE4UPH5iW7UfW+s1HaNPyYcisf95h4KiOy5P4GtZgEK/J/K9cbQr rRvg== X-Gm-Message-State: AOAM533xMYEGHtKI5bdT4RzvZ4tk3P8VIl5Xxg+1btU0RcJF34O+ZiUJ KVhBWvOH9lKBbQQkReqwOQ== X-Google-Smtp-Source: ABdhPJxCOvSZJjgV8dmpjz1absHf9rtM/YAUdxiPjEAYsj3UD951nAJSsafqEKqv/yrVgqyHrCCCDg== X-Received: by 2002:a17:90a:8b0e:: with SMTP id y14mr3967234pjn.57.1605183373347; Thu, 12 Nov 2020 04:16:13 -0800 (PST) Received: from localhost.localdomain ([221.124.243.27]) by smtp.gmail.com with ESMTPSA id d11sm6907485pjm.18.2020.11.12.04.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 04:16:12 -0800 (PST) From: Peilin Ye To: Daniel Vetter Cc: Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , Jiri Slaby , Tetsuo Handa , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Peilin Ye , Daniel Vetter Subject: [PATCH v3 RFC 5/5] fbcon: Avoid using FNTCHARCNT() and hard-coded built-in font charcount Date: Thu, 12 Nov 2020 07:15:22 -0500 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org For user-provided fonts, the framebuffer layer is using a magic negative-indexing macro, FNTCHARCNT(), to keep track of their number of characters: #define FNTCHARCNT(fd) (((int *)(fd))[-3]) For built-in fonts, it is using hard-coded values (256). This results in something like the following: map.length = (ops->p->userfont) ? FNTCHARCNT(ops->p->fontdata) : 256; This is unsatisfactory. In fact, there is already a `charcount` field in our virtual console descriptor (see `struct console_font` inside `struct vc_data`), let us use it: map.length = vc->vc_font.charcount; Recently we added a `charcount` field to `struct font_desc`. Use it to set `vc->vc_font.charcount` properly. The idea is: - We only use FNTCHARCNT() on `vc->vc_font.data` and `p->fontdata`. Assume FNTCHARCNT() is working as intended; - Whenever `vc->vc_font.data` is set, also set `vc->vc_font.charcount` properly; - We can now replace `FNTCHARCNT(vc->vc_font.data)` with `vc->vc_font.charcount`; - Since `p->fontdata` always point to the same font data buffer with `vc->vc_font.data`, we can also replace `FNTCHARCNT(p->fontdata)` with `vc->vc_font.charcount`. In conclusion, set `vc->vc_font.charcount` properly in fbcon_startup(), fbcon_init(), fbcon_set_disp() and fbcon_do_set_font(), then replace FNTCHARCNT() with `vc->vc_font.charcount`. No more if-else between negative-indexing macros and hard-coded values. Do not include in fbcon_rotate.c and tileblit.c, since they no longer need it. Depends on patch "Fonts: Add charcount field to font_desc". Suggested-by: Daniel Vetter Signed-off-by: Peilin Ye --- v2: https://lore.kernel.org/lkml/20201028155139.1220549-1-yepeilin.cs@gmail.com/ Boot-tested only, thus the "RFC". Looking forward to suggestions about how to test this properly. Thank you! I am not very sure about the statement "`p->fontdata` always point to the same font data buffer with `vc->vc_font.data`". It is concluded from code reading. Change in v3: - Do not touch fbcon_copy_font() since we removed it in patch "console: Delete unused con_font_copy() callback implementations" Changes in v2: - Try avoid using FNTCHARCNT() altogether, instead of only changing a little bit (Daniel) - Set `vc->vc_font.charcount` properly, in fbcon_startup(), fbcon_init(), fbcon_set_disp() and fbcon_do_set_font() - Replace hard-coded 256 whenever possible drivers/video/fbdev/core/fbcon.c | 57 +++++++++---------------- drivers/video/fbdev/core/fbcon_rotate.c | 3 +- drivers/video/fbdev/core/tileblit.c | 4 +- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 26d1b0916692..06520667fc07 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1004,7 +1004,7 @@ static const char *fbcon_startup(void) vc->vc_font.width = font->width; vc->vc_font.height = font->height; vc->vc_font.data = (void *)(p->fontdata = font->data); - vc->vc_font.charcount = 256; /* FIXME Need to support more fonts */ + vc->vc_font.charcount = font->charcount; } else { p->fontdata = vc->vc_font.data; } @@ -1032,7 +1032,7 @@ static void fbcon_init(struct vc_data *vc, int init) struct vc_data **default_mode = vc->vc_display_fg; struct vc_data *svc = *default_mode; struct fbcon_display *t, *p = &fb_display[vc->vc_num]; - int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; + int logo = 1, new_rows, new_cols, rows, cols; int cap, ret; if (WARN_ON(info_idx == -1)) @@ -1068,6 +1068,7 @@ static void fbcon_init(struct vc_data *vc, int init) fvc->vc_font.data); vc->vc_font.width = fvc->vc_font.width; vc->vc_font.height = fvc->vc_font.height; + vc->vc_font.charcount = fvc->vc_font.charcount; p->userfont = t->userfont; if (p->userfont) @@ -1083,17 +1084,13 @@ static void fbcon_init(struct vc_data *vc, int init) vc->vc_font.width = font->width; vc->vc_font.height = font->height; vc->vc_font.data = (void *)(p->fontdata = font->data); - vc->vc_font.charcount = 256; /* FIXME Need to - support more fonts */ + vc->vc_font.charcount = font->charcount; } } - if (p->userfont) - charcnt = FNTCHARCNT(p->fontdata); - vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; - if (charcnt == 256) { + if (vc->vc_font.charcount == 256) { vc->vc_hi_font_mask = 0; } else { vc->vc_hi_font_mask = 0x100; @@ -1358,7 +1355,7 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, struct vc_data **default_mode, *vc; struct vc_data *svc; struct fbcon_ops *ops = info->fbcon_par; - int rows, cols, charcnt = 256; + int rows, cols; p = &fb_display[unit]; @@ -1378,12 +1375,11 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, vc->vc_font.data = (void *)(p->fontdata = t->fontdata); vc->vc_font.width = (*default_mode)->vc_font.width; vc->vc_font.height = (*default_mode)->vc_font.height; + vc->vc_font.charcount = (*default_mode)->vc_font.charcount; p->userfont = t->userfont; if (p->userfont) REFCOUNT(p->fontdata)++; } - if (p->userfont) - charcnt = FNTCHARCNT(p->fontdata); var->activate = FB_ACTIVATE_NOW; info->var.activate = var->activate; @@ -1393,7 +1389,7 @@ static void fbcon_set_disp(struct fb_info *info, struct fb_var_screeninfo *var, ops->var = info->var; vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; - if (charcnt == 256) { + if (vc->vc_font.charcount == 256) { vc->vc_hi_font_mask = 0; } else { vc->vc_hi_font_mask = 0x100; @@ -2027,7 +2023,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, */ if (pitch <= 0) return -EINVAL; - size = CALC_FONTSZ(vc->vc_font.height, pitch, FNTCHARCNT(vc->vc_font.data)); + size = CALC_FONTSZ(vc->vc_font.height, pitch, vc->vc_font.charcount); if (size > FNTSIZE(vc->vc_font.data)) return -EINVAL; } @@ -2075,7 +2071,7 @@ static int fbcon_switch(struct vc_data *vc) struct fbcon_ops *ops; struct fbcon_display *p = &fb_display[vc->vc_num]; struct fb_var_screeninfo var; - int i, ret, prev_console, charcnt = 256; + int i, ret, prev_console; info = registered_fb[con2fb_map[vc->vc_num]]; ops = info->fbcon_par; @@ -2152,10 +2148,7 @@ static int fbcon_switch(struct vc_data *vc) vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; - if (p->userfont) - charcnt = FNTCHARCNT(vc->vc_font.data); - - if (charcnt > 256) + if (vc->vc_font.charcount > 256) vc->vc_complement_mask <<= 1; updatescrollmode(p, info, vc); @@ -2405,31 +2398,27 @@ static void set_vc_hi_font(struct vc_data *vc, bool set) } } -static int fbcon_do_set_font(struct vc_data *vc, int w, int h, +static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, const u8 * data, int userfont) { struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; struct fbcon_ops *ops = info->fbcon_par; struct fbcon_display *p = &fb_display[vc->vc_num]; int resize; - int cnt; char *old_data = NULL; resize = (w != vc->vc_font.width) || (h != vc->vc_font.height); if (p->userfont) old_data = vc->vc_font.data; - if (userfont) - cnt = FNTCHARCNT(data); - else - cnt = 256; vc->vc_font.data = (void *)(p->fontdata = data); if ((p->userfont = userfont)) REFCOUNT(data)++; vc->vc_font.width = w; vc->vc_font.height = h; - if (vc->vc_hi_font_mask && cnt == 256) + vc->vc_font.charcount = charcount; + if (vc->vc_hi_font_mask && charcount == 256) set_vc_hi_font(vc, false); - else if (!vc->vc_hi_font_mask && cnt == 512) + else if (!vc->vc_hi_font_mask && charcount == 512) set_vc_hi_font(vc, true); if (resize) { @@ -2496,9 +2485,10 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, if (!new_data) return -ENOMEM; + memset(new_data, 0, FONT_EXTRA_WORDS * sizeof(int)); + new_data += FONT_EXTRA_WORDS * sizeof(int); FNTSIZE(new_data) = size; - FNTCHARCNT(new_data) = charcount; REFCOUNT(new_data) = 0; /* usage counter */ for (i=0; i< charcount; i++) { memcpy(new_data + i*h*pitch, data + i*32*pitch, h*pitch); @@ -2524,7 +2514,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, break; } } - return fbcon_do_set_font(vc, font->width, font->height, new_data, 1); + return fbcon_do_set_font(vc, font->width, font->height, charcount, new_data, 1); } static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name) @@ -2540,7 +2530,7 @@ static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, cha font->width = f->width; font->height = f->height; - return fbcon_do_set_font(vc, f->width, f->height, f->data, 0); + return fbcon_do_set_font(vc, f->width, f->height, f->charcount, f->data, 0); } static u16 palette_red[16]; @@ -3009,7 +2999,6 @@ void fbcon_get_requirement(struct fb_info *info, struct fb_blit_caps *caps) { struct vc_data *vc; - struct fbcon_display *p; if (caps->flags) { int i, charcnt; @@ -3018,11 +3007,9 @@ void fbcon_get_requirement(struct fb_info *info, vc = vc_cons[i].d; if (vc && vc->vc_mode == KD_TEXT && info->node == con2fb_map[i]) { - p = &fb_display[i]; caps->x |= 1 << (vc->vc_font.width - 1); caps->y |= 1 << (vc->vc_font.height - 1); - charcnt = (p->userfont) ? - FNTCHARCNT(p->fontdata) : 256; + charcnt = vc->vc_font.charcount; if (caps->len < charcnt) caps->len = charcnt; } @@ -3032,11 +3019,9 @@ void fbcon_get_requirement(struct fb_info *info, if (vc && vc->vc_mode == KD_TEXT && info->node == con2fb_map[fg_console]) { - p = &fb_display[fg_console]; caps->x = 1 << (vc->vc_font.width - 1); caps->y = 1 << (vc->vc_font.height - 1); - caps->len = (p->userfont) ? - FNTCHARCNT(p->fontdata) : 256; + caps->len = vc->vc_font.charcount; } } } diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c index ac72d4f85f7d..ef1d421c261a 100644 --- a/drivers/video/fbdev/core/fbcon_rotate.c +++ b/drivers/video/fbdev/core/fbcon_rotate.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "fbcon.h" #include "fbcon_rotate.h" @@ -33,7 +32,7 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) src = ops->fontdata = vc->vc_font.data; ops->cur_rotate = ops->p->con_rotate; - len = (!ops->p->userfont) ? 256 : FNTCHARCNT(src); + len = vc->vc_font.charcount; s_cellsize = ((vc->vc_font.width + 7)/8) * vc->vc_font.height; d_cellsize = s_cellsize; diff --git a/drivers/video/fbdev/core/tileblit.c b/drivers/video/fbdev/core/tileblit.c index 628fe5e010c0..e2cc0cb6d50e 100644 --- a/drivers/video/fbdev/core/tileblit.c +++ b/drivers/video/fbdev/core/tileblit.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "fbcon.h" @@ -145,8 +144,7 @@ void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info) map.width = vc->vc_font.width; map.height = vc->vc_font.height; map.depth = 1; - map.length = (ops->p->userfont) ? - FNTCHARCNT(ops->p->fontdata) : 256; + map.length = vc->vc_font.charcount; map.data = ops->p->fontdata; info->tileops->fb_settile(info, &map); }