From patchwork Mon Nov 2 09:36:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11873243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0BB8C00A89 for ; Mon, 2 Nov 2020 09:37:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D93D206F8 for ; Mon, 2 Nov 2020 09:37:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ouivo3Wk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D93D206F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF3946E0A1; Mon, 2 Nov 2020 09:37:15 +0000 (UTC) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by gabe.freedesktop.org (Postfix) with ESMTPS id 174636E0A1 for ; Mon, 2 Nov 2020 09:37:15 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id y14so10586091pfp.13 for ; Mon, 02 Nov 2020 01:37:15 -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=q4LWjOQb48RbMvuqunvROMBYqbWJviRmRbs1farYf+o=; b=Ouivo3WkaZWDdXarHlxfc76m/TrdvxXtNjxs/qxYSq5z1VkleGC5Biq3uMuBsyswOw sewYi9DabhWO7RN0Qvtwl9XEYrmkScHJrmHPoSUlYwXuGUrsfb7uYXvkM4O+iHn6kqh+ MYJIDi6A4Ufxb+P5QQUIB2ztW1TBwwoaxRAWXfj904qfJAiNKy6X2oafViYxJR1oq5qT fgm9qCtv3huwI6tLzKwUE8+0Xu9caqDo2RTNhA7Fx8KTtWLom/JvHNfI2YHgAwodKNxn sGmDA0j9bSydLptOUNPWxXJzv5RZcEvHgWExANOO60Sn8cR6+dxA/yNo3PdA8jR5DQcU +1Ow== 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=q4LWjOQb48RbMvuqunvROMBYqbWJviRmRbs1farYf+o=; b=h6E99Q29cw3TTRZsbaYOyLkXKSaXspOC2EVfnFVbIe/2uuf4h59BDWpHYfcmQfb6wz 24uWJ9XeBxZZJFJEEJmfMUjkrNEZW0vJ3zVScY108/hD3pgPyKydQ41hJKoNP8/gFTSm Kp8rQEEhmUK6zis81FOdG8AkXNK3U1l9dVQYB1xzXf0Dcmzyd74avX1YCK+pAsKV5LFS RcaERZTtWs/tIt0FC3E3ZcyDrEoogiqELbpDP6iT4+mFvwlNieLWI9q5YXUJpSa13rl2 PkdHXi2xStorLdYf4/uFSmmCGUUCoLXPcsm0CzBBIaaRcKFgrpd2jdsIEecqbc2Pqd1e C58g== X-Gm-Message-State: AOAM530ww/oGNd3I7riGs8p7QyCzpFDWzekhleYh9nxTWa85MxATTNbU UV8pwMxYQh6JhxDuRWlJbg== X-Google-Smtp-Source: ABdhPJzsH5NB3PxiruEjGrp4JTwVXQZfViSpD41UawE+gLt4Mib6M7rMtc3KzqmkqFgSe0xUpuE/iA== X-Received: by 2002:a62:1991:0:b029:155:f476:2462 with SMTP id 139-20020a6219910000b0290155f4762462mr21521857pfz.43.1604309834682; Mon, 02 Nov 2020 01:37:14 -0800 (PST) Received: from localhost.localdomain (59-125-13-244.HINET-IP.hinet.net. [59.125.13.244]) by smtp.gmail.com with ESMTPSA id 199sm5566013pgg.18.2020.11.02.01.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 01:37:13 -0800 (PST) From: Peilin Ye To: Daniel Vetter , Greg Kroah-Hartman , Jiri Slaby , Thomas Winischhofer Subject: [PATCH v2 1/2] console: Remove dummy con_font_op() callback implementations Date: Mon, 2 Nov 2020 04:36:05 -0500 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, linux-usb@vger.kernel.org, Nicolas Pitre , Tetsuo Handa , Bartlomiej Zolnierkiewicz , "Gustavo A . R . Silva" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, George Kennedy , Peilin Ye , Nathan Chancellor , Peter Rosin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" `struct console_font` is a UAPI structure, thus ideally should not be used for kernel internal abstraction. Remove some dummy .con_font_set, .con_font_default and .con_font_copy `struct consw` callback implementations, to make it cleaner. Suggested-by: Daniel Vetter Signed-off-by: Peilin Ye --- Change in v2: - [v2 2/2] no longer Cc: stable, so do not Cc: stable Context: https://lore.kernel.org/lkml/CAKMK7uFY2zv0adjKJ_ORVFT7Zzwn075MaU0rEU7_FuqENLR=UA@mail.gmail.com/ drivers/usb/misc/sisusbvga/sisusb_con.c | 21 --------------------- drivers/video/console/dummycon.c | 20 -------------------- 2 files changed, 41 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index c63e545fb105..dfa0d5ce6012 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c @@ -1345,24 +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 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, @@ -1375,9 +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, - .con_font_copy = sisusbdummycon_font_copy, }; int diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 2a0d0bda7faa..f1711b2f9ff0 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -124,23 +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; -} - -static int dummycon_font_copy(struct vc_data *vc, int con) -{ - return 0; -} - /* * The console `switch' structure for the dummy console * @@ -159,8 +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, - .con_font_copy = dummycon_font_copy, }; EXPORT_SYMBOL_GPL(dummy_con); From patchwork Mon Nov 2 09:37:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 11873249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D504C388F2 for ; Mon, 2 Nov 2020 09:38:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4CF3222E8 for ; Mon, 2 Nov 2020 09:38:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e8iOFOWn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4CF3222E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 394BC6E454; Mon, 2 Nov 2020 09:38:57 +0000 (UTC) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id A5E916E454 for ; Mon, 2 Nov 2020 09:38:56 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id 13so10615918pfy.4 for ; Mon, 02 Nov 2020 01:38:56 -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=KIkUS/F/h0cPY8zoQYXrrVqLmu2PvOEJdmO7uBtIRmA=; b=e8iOFOWnoSM+T3VgJIdvUIoDbCbNf3KV95reaRCqBmp2FvsCbL4CFcbuUYPkHqxmkc YhdotRfTN81ubPChT7zXGTUsqyNxgeFKNBMCf3SzBPvO9TaXdr+qN9rINCzpASxuYsnj N3ZothOUEwZsCsqVm4UXP/NadPUfKNBFMjM6A6dMU7y2wX98kCALGuMEOy3CIoZiAcDP kIvitL06u2RajJIyUxt65QaCyZDajX7Gqg1UkiyD+jmHwo8W88hGTfXBUmFaJ3gAMlcI cEe5O++yDuXwJtyM44W+wXdYOtwJ4mj5w4oXpjaqcWkEeq9B6ecjw1avm597BfmDlIBi xD1g== 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=KIkUS/F/h0cPY8zoQYXrrVqLmu2PvOEJdmO7uBtIRmA=; b=cmQhHCXdsfOUhjYYlU4OAOtAqSfE7wfeabXmn3K5QrAXX24UhfpWyx4iwFOPGS0B/O iWQZzeoLu7fYCIqmmRqJ+fOJ+wmSU8H/jRGBRQj73Eu3yiArKu6hET8glAX55SQU/X14 C7mpScW4rhHgpXLjXwmX5HZJhKyCBg7ymQOL7Df0dbc9JmGmV9HCEzNvfHdVMk1BsrRQ WNA6r8owDSUEhKjch/TvVvT0Sy7fWYs1+Ud27EegcziNBW4pBYECQOwWfQg3/8U0pFrX qj2IAZGAVlCZG1VVMsDzR4sMKspqP/Scv+FiCu4GaBNG59lbIadweMG5ZUcP4SZJS9F7 y9oA== X-Gm-Message-State: AOAM5325zFYIPINyLk6KTLl/N7CkNlEA6O1pZhRDrV9XGQKCROPy8bbt lHpa8jxBwEeyyOczkEi7Vg== X-Google-Smtp-Source: ABdhPJzCgNIMLBogFRg0xQa7AqfDjpwCrCxnaBYR0EmavPxwn1TrqXYVqyom19qz7drAlhjDOwtHSg== X-Received: by 2002:a05:6a00:c8:b029:18b:b0e:e51 with SMTP id e8-20020a056a0000c8b029018b0b0e0e51mr1972116pfj.37.1604309936301; Mon, 02 Nov 2020 01:38:56 -0800 (PST) Received: from localhost.localdomain (59-125-13-244.HINET-IP.hinet.net. [59.125.13.244]) by smtp.gmail.com with ESMTPSA id u11sm12574877pfk.164.2020.11.02.01.38.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 01:38:55 -0800 (PST) From: Peilin Ye To: Daniel Vetter , Greg Kroah-Hartman , Jiri Slaby , Thomas Winischhofer Subject: [PATCH v2 2/2] tty/vt: Avoid passing struct console_font_op to con_font_copy() Date: Mon, 2 Nov 2020 04:37:55 -0500 Message-Id: <72c954371ed9b1d050901b2d498a979017de8a3c.1604306433.git.yepeilin.cs@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, linux-usb@vger.kernel.org, Nicolas Pitre , Tetsuo Handa , Bartlomiej Zolnierkiewicz , "Gustavo A . R . Silva" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, George Kennedy , Peilin Ye , Nathan Chancellor , Peter Rosin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" con_font_op() is passing an entire `struct console_font_op *` to con_font_copy(), but con_font_copy() only uses `op->height`. Additionally, con_font_copy() is silently assigning the unsigned `op->height` to the signed `con`, then pass it to fbcon_copy_font(). Let con_font_copy() and fbcon_copy_font() pass an unsigned int directly. Also, add a comment in con_font_op() for less confusion, since ideally `op->height` should not be used as a console index, as the field name suggests. This patch depends on patch "console: Remove dummy con_font_op() callback implementations". Suggested-by: Daniel Vetter Signed-off-by: Peilin Ye --- con_font_set(), con_font_get() and con_font_default() also pass an entire `console_font_op`. con_font_get() and con_font_default() actually update the structure (later copied to userspace), so let them be. con_font_set() does not update the structure, but it uses all fields of it except `op`. Avoiding passing `console_font_op` to con_font_set() will thus make its signature pretty long (6 parameters). Changes in v2: - Remove redundant `con < 0` check in con_font_copy() (kernel test robot ) - Remove unnecessary range check in fbcon_copy_font(). con_font_copy() calls vc_cons_allocated(), which does the check - Do not Cc: stable - Rewrite the title and commit message accordingly drivers/tty/vt/vt.c | 8 ++++---- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 9506a76f3ab6..27821ef97b13 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4704,9 +4704,8 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op) return rc; } -static int con_font_copy(struct vc_data *vc, struct console_font_op *op) +static int con_font_copy(struct vc_data *vc, unsigned int con) { - int con = op->height; int rc; @@ -4715,7 +4714,7 @@ static int con_font_copy(struct vc_data *vc, struct console_font_op *op) rc = -EINVAL; else if (!vc->vc_sw->con_font_copy) rc = -ENOSYS; - else if (con < 0 || !vc_cons_allocated(con)) + else if (!vc_cons_allocated(con)) rc = -ENOTTY; else if (con == vc->vc_num) /* nothing to do */ rc = 0; @@ -4735,7 +4734,8 @@ int con_font_op(struct vc_data *vc, struct console_font_op *op) case KD_FONT_OP_SET_DEFAULT: return con_font_default(vc, op); case KD_FONT_OP_COPY: - return con_font_copy(vc, op); + /* uses op->height as a console index */ + return con_font_copy(vc, op->height); } return -ENOSYS; } diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index cef437817b0d..cb5b5705ea71 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2451,7 +2451,7 @@ 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) +static int fbcon_copy_font(struct vc_data *vc, unsigned int con) { struct fbcon_display *od = &fb_display[con]; struct console_font *f = &vc->vc_font; diff --git a/include/linux/console.h b/include/linux/console.h index 4b1e26c4cb42..34855d3f2afd 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -62,7 +62,7 @@ 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_font_copy)(struct vc_data *vc, unsigned 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,