From patchwork Thu Jan 18 07:57:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763880 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B51E11CB0; Thu, 18 Jan 2024 07:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564685; cv=none; b=FevolO1ACI6y499Tos29gEuPYbwjCQePSfJP5hBVcDNg57ZZgHWcHODqKphL7KN8mEv8VycBpJWhSsAEmBP3SwQKt5YnV5LeWI5mFLcr7rGIKo71SGq19iSo4OlVkj/emOH/DaVzTCOC4ra0jk55mVXina4eJF6qOIOf+68FrKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564685; c=relaxed/simple; bh=w11xF62sAxvtyjUlJ/rSiBQfEK5Y+txgHz5Oan2+3RE=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=hv0vo+0PwVqNF4LuCnmiDeR0baCzAYjh19brPSgm0mfDoF2uIbwBRxXxEP9LG3iH4sLLJTApirEAgJkmXeFqi/i6jh0ZGDYTpe5Hd1a2t6psP1TdqWFkuoRqYTYE0Lob5Goq0tRFq+JZYL8CxefX9egLF8trvdke5/NYqXT4EC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tsuk5Wsv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tsuk5Wsv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FF6FC43601; Thu, 18 Jan 2024 07:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564684; bh=w11xF62sAxvtyjUlJ/rSiBQfEK5Y+txgHz5Oan2+3RE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tsuk5WsvE8kttQs9Uslhi1gQj3HZhcnrmcKYquIllH+pAmezRErO18x9wDQGx+Zey VXVdfuHSJ0W+qpLR82rx48WNdfy8bhxpHoZu65BAv46BfOlHLnI/z7Hc1AFiJscrxR IlhRfkEfcDwCs/KSNj5r16ELxBx4Jo8AW3hAC+xK3qrlqNsgOXkkpQrvTI6Kl5xBPj GaDCAgdcIcFa6YeSRnzM2qofT73byLfyw72mRxuWFXCQf4SFb+M0ZPj4u/GT6c66Mm 9eKrYHmY3vZF4iPL22evWRJs9u7wa9grHgP+74PhCyGNG4lrqNzfmq99Rh57UpXEPq bLypcGGZ+zmzg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 01/45] vgacon: inline vc_scrolldelta_helper() into vgacon_scrolldelta() Date: Thu, 18 Jan 2024 08:57:12 +0100 Message-ID: <20240118075756.10541-2-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since commit 74d58cd48a8f ("USB: sisusbvga: remove console support"), vgacon_scrolldelta() is the only user of vc_scrolldelta_helper(). Inline the helper into vgacon_scrolldelta() and drop it. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/tty/vt/vt.c | 40 ---------------------------------- drivers/video/console/vgacon.c | 36 ++++++++++++++++++++++++++++-- include/linux/vt_kern.h | 3 --- 3 files changed, 34 insertions(+), 45 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 156efda7c80d..3f3f7c216819 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4748,43 +4748,3 @@ void vcs_scr_updated(struct vc_data *vc) { notify_update(vc); } - -void vc_scrolldelta_helper(struct vc_data *c, int lines, - unsigned int rolled_over, void *base, unsigned int size) -{ - unsigned long ubase = (unsigned long)base; - ptrdiff_t scr_end = (void *)c->vc_scr_end - base; - ptrdiff_t vorigin = (void *)c->vc_visible_origin - base; - ptrdiff_t origin = (void *)c->vc_origin - base; - int margin = c->vc_size_row * 4; - int from, wrap, from_off, avail; - - /* Turn scrollback off */ - if (!lines) { - c->vc_visible_origin = c->vc_origin; - return; - } - - /* Do we have already enough to allow jumping from 0 to the end? */ - if (rolled_over > scr_end + margin) { - from = scr_end; - wrap = rolled_over + c->vc_size_row; - } else { - from = 0; - wrap = size; - } - - from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; - avail = (origin - from + wrap) % wrap; - - /* Only a little piece would be left? Show all incl. the piece! */ - if (avail < 2 * margin) - margin = 0; - if (from_off < margin) - from_off = 0; - if (from_off > avail - margin) - from_off = avail; - - c->vc_visible_origin = ubase + (from + from_off) % wrap; -} -EXPORT_SYMBOL_GPL(vc_scrolldelta_helper); diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 8ef1579fa57f..9176fff9ce6e 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -138,8 +138,40 @@ static inline void vga_set_mem_top(struct vc_data *c) static void vgacon_scrolldelta(struct vc_data *c, int lines) { - vc_scrolldelta_helper(c, lines, vga_rolled_over, (void *)vga_vram_base, - vga_vram_size); + unsigned long scr_end = c->vc_scr_end - vga_vram_base; + unsigned long vorigin = c->vc_visible_origin - vga_vram_base; + unsigned long origin = c->vc_origin - vga_vram_base; + int margin = c->vc_size_row * 4; + int from, wrap, from_off, avail; + + /* Turn scrollback off */ + if (!lines) { + c->vc_visible_origin = c->vc_origin; + return; + } + + /* Do we have already enough to allow jumping from 0 to the end? */ + if (vga_rolled_over > scr_end + margin) { + from = scr_end; + wrap = vga_rolled_over + c->vc_size_row; + } else { + from = 0; + wrap = vga_vram_size; + } + + from_off = (vorigin - from + wrap) % wrap + lines * c->vc_size_row; + avail = (origin - from + wrap) % wrap; + + /* Only a little piece would be left? Show all incl. the piece! */ + if (avail < 2 * margin) + margin = 0; + if (from_off < margin) + from_off = 0; + if (from_off > avail - margin) + from_off = avail; + + c->vc_visible_origin = vga_vram_base + (from + from_off) % wrap; + vga_set_mem_top(c); } diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index c1f5aebef170..a789ea3ed2a0 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -168,7 +168,4 @@ void vt_set_led_state(unsigned int console, int leds); void vt_kbd_con_start(unsigned int console); void vt_kbd_con_stop(unsigned int console); -void vc_scrolldelta_helper(struct vc_data *c, int lines, - unsigned int rolled_over, void *_base, unsigned int size); - #endif /* _VT_KERN_H */ From patchwork Thu Jan 18 07:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765115 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8307C13AF9; Thu, 18 Jan 2024 07:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564687; cv=none; b=olLEPREOyn+nG3nMG7TBU/TPKmLDxkWYRfnBfmU6T9BAM0DjnoG/eZompQZqb6lob3y0BVTW6T/nkAgv8gYC395rX4XxS9K8Lxh7nDAxxgPQ2xcnkqMYnvCk5EqMetAJJZTZzlhrw3m5Fex+Ovr1qchsBlTcanMKYd1Qxz+u2EM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564687; c=relaxed/simple; bh=VF67ScvZaWBLLIl5rAX1Kh4YdbBo6nKFZPHrtIWu1Y8=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=Ti+lcsgr/huevKPH6Q0nRQRZXxt3dG/phLHD7Ub7oI3at3oZVWhSeMmyak5ntVFpSxpiSPOtqArarEPkfsK2HwG8a7s/1PPs3Pc7gHCGy1wmm3Sng8fVQXV3xP4IRjANnqzc1k9avo7ABXZx3DwzxNNIoxDWoVG/OQMS7SSbZOM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hzV9XM2o; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hzV9XM2o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A187C433F1; Thu, 18 Jan 2024 07:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564687; bh=VF67ScvZaWBLLIl5rAX1Kh4YdbBo6nKFZPHrtIWu1Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzV9XM2oma7CXY2prJ5hO4Kbts/86byd0p9nMAE71rQBKPNnKmCaFUuJhksZ6tiWq A4DeNHDswadUILCIUtRzvkMMFjSHKrClNwXM8YlKPhiey55Ge1Geu35zcySFp7xrIh g3zCt4gtKuBSfXYLHfm1F3DNLjkpXXasYfrY1gwsZlY8A+rb5ZRiJ8hYADBevSK/GZ wecsF4s50veThCCoCiLIMPItmjENtSJPPTaH2HzrGfrJLUeZlQxmNwskMoH/eQTHbz LJ6oISId7gI8Gz4YxFtwAYrDidRreY6Ay3kys2ZXctW2eftCVbxdgvPa/XN6HosL4a /5zquQEqoeZSA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Daniel Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 02/45] fbcon: make display_desc a static array in fbcon_startup() Date: Thu, 18 Jan 2024 08:57:13 +0100 Message-ID: <20240118075756.10541-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 display_desc is a pointer to a RO string. Instead, switch display_desc to a static array as we are used to. It BTW saves unnecessary 8B on the stack. Signed-off-by: Jiri Slaby (SUSE) Cc: Daniel Vetter Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/fbdev/core/fbcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 63af6ab034b5..a8c32cb4c878 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -921,7 +921,7 @@ static void display_to_var(struct fb_var_screeninfo *var, static const char *fbcon_startup(void) { - const char *display_desc = "frame buffer device"; + static const char display_desc[] = "frame buffer device"; struct fbcon_display *p = &fb_display[fg_console]; struct vc_data *vc = vc_cons[fg_console].d; const struct font_desc *font = NULL; From patchwork Thu Jan 18 07:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763879 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A96C41BDFD; Thu, 18 Jan 2024 07:58:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564689; cv=none; b=mDeagyyNX3faHD3xRpLttFDdf6Q8mPSc+VdHd4vTTWo4KGGZ8V+vXU0W5AnE7gtRZz0mbCKwu6/Nyh6lPqrnYExJnS2l1YqT/DPxyBYCkdRzYFM3kuSnD7lEhGbz7phzHnhl6Mb5DrLsrNMON5MEXM55Bn03H6NbzNTZTAsWQrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564689; c=relaxed/simple; bh=JLskyX1cYZHzZMmvuU1LzSTACKKk6cE/XiYsShkR8C4=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=O4lX+jvsjY33OBMrVkLPfbLP2HxGu7UtEC26gCTdngTrekwChp0ijftqA8ue08SWdqMCowPPoOwmP5E4yVuB17Eyn6vSDGWn1Rt8sQmVD7Lc9YOJfIkgm/c4D6X8VxWMV2lQW9HhT3Cx9sQT5HsqseGLdOM8uYGh9gz4uLDhhCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vJESU3IA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vJESU3IA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D71D0C433C7; Thu, 18 Jan 2024 07:58:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564689; bh=JLskyX1cYZHzZMmvuU1LzSTACKKk6cE/XiYsShkR8C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vJESU3IAqd69GLqIiFKDFIagNUQv3n+FfY2/R5MVHbje30/2WTE86E8phmkCHG3Eu 21hxB3uIcNRnCYuU8yD+JblDqnZPUXsX3iIzO4vcoK46t4mTo4n28msoJ1pLIhPxjm k0GPU3RwtmPqcCOYPn6xxigoG2RSXbikDJG8cnQOpe5/0KvPfE3qQaRDJbBqw700OK N9mSdQd9MinsTAuwV1Rn0GaIUvjqwJkaHnQ7o+vSicWMVJ0xjeVDnVgd+oEobig4dW GxMIX6K8jDouI751V07ITF6XQ9WAtPji2kmmU+LsoO9K+K1tVljjr5ZNSMsv1IHSKx epMMnNfmD+x7A== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Martin Hostettler Subject: [PATCH 03/45] tty: vt: fix 20 vs 0x20 typo in EScsiignore Date: Thu, 18 Jan 2024 08:57:14 +0100 Message-ID: <20240118075756.10541-4-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The if (c >= 20 && c <= 0x3f) test added in commit 7a99565f8732 is wrong. 20 is DC4 in ascii and it makes no sense to consider that as the bottom limit. Instead, it should be 0x20 as in the other test in the commit above. This is supposed to NOT change anything as we handle interesting 20-0x20 asciis far before this if. So for sakeness, change to 0x20 (which is SPACE). Signed-off-by: Jiri Slaby (SUSE) Fixes: 7a99565f8732 ("vt: ignore csi sequences with intermediate characters.") Cc: Martin Hostettler Link: https://lore.kernel.org/all/ZaP45QY2WEsDqoxg@neutronstar.dyndns.org/ --- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 3f3f7c216819..55ce6cdecbca 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2469,7 +2469,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) } return; case EScsiignore: - if (c >= 20 && c <= 0x3f) + if (c >= 0x20 && c <= 0x3f) return; vc->vc_state = ESnormal; return; From patchwork Thu Jan 18 07:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765114 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69D071E493; Thu, 18 Jan 2024 07:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564691; cv=none; b=JD8708TUFoHpKd5guJ2uBjUe22oA4hR7ZBR2r3i/T4ziEY0X0I72ByjoWDY97eaLr5/YnhbZfic4KfkdceifI5y6r7nTf76EsUaWz9UEXNOLfsPCn2jrYoZ214glrPsing5dBNdzXvxugnpOGlJN2Y9LSlxrqYFE7qCSjOMqly0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564691; c=relaxed/simple; bh=rUROH6mYOVI5bovPWhIiic94alNwwSPkZdh64JHmGT4=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=kfOyQGm2NXnWgku+6fQ6mjj63z+/urrPJ1BoboiKMOYTV0miaH0aBiBTavHVZpwqFg/Wm6j0YmqMuZYKQxELozaBapxqV/0N74HloIizwjjWygcVtMiOuxViPoIhfFLoTIWH4BwwAwIDQg0xQvrSZpkUiErGs0H1jG2qtlnkuHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hUHWWmny; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hUHWWmny" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBE0AC43390; Thu, 18 Jan 2024 07:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564691; bh=rUROH6mYOVI5bovPWhIiic94alNwwSPkZdh64JHmGT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUHWWmnyO52C8o8MDzELpYndROckNu3ZUgrlPoxmX3vamOdpNpW6a9pfmy0vu30wb bnpvPy6/VwkelT37nZ5RYyYDuxlXckLRwkx9TP6zvB6kMLBSv2eE4YXBkCY4AKXPe3 dwQwO4hOZAoZfJ2lUl6p7+fvo6j6l7MwWFJCDfZcR2qvk/ez4aRZtA2YK5sn3e0V7U 49MaShu2oQufFg4SFJp4SwTVy9l7Qpqp/uMzX58XVU6AdSvFQirMPLbMH6GJhVaPJz WLZcrpsA9SJNDBggVHz2nqdDEGYOsGN89Z05CTix/oWe95F6VpuB+JodskmEtCDIar 5XvZuCFCOOUIw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 04/45] tty: vt: expect valid vc when in tty ops Date: Thu, 18 Jan 2024 08:57:15 +0100 Message-ID: <20240118075756.10541-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 At least since commits feebed6515a1 ("tty: shutdown method") and bc1e99d93f09 ("TTY: vt, add ->install"), tty->driver_data in vc is expected to be set since tty_operations::install() till ::cleanup(). So the checks of !tty->driver_data (aka !vc) in: * vc_do_resize() by tty -> ioctl(TIOCSWINSZ) -> vt_resize() * do_con_write() by tty -> tty_operations::write()/::put_char() * con_flush_chars() by tty -> ::flush_chars() are all superfluous. And also, holding a console lock is not needed to fetch tty->driver_data. Note there is even a stale comment in con_flush_chars() about a race between that and con_close(). But con_close() does not set tty->driver_data to NULL for years already. Drop all these in a hope I am not terribly mistaken. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 55ce6cdecbca..e131edea00da 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1154,9 +1154,6 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, WARN_CONSOLE_UNLOCKED(); - if (!vc) - return -ENXIO; - user = vc->vc_resize_user; vc->vc_resize_user = 0; @@ -2852,7 +2849,7 @@ static int do_con_write(struct tty_struct *tty, const u8 *buf, int count) }; int c, tc, n = 0; unsigned int currcons; - struct vc_data *vc; + struct vc_data *vc = tty->driver_data; struct vt_notifier_param param; bool rescan; @@ -2860,13 +2857,6 @@ static int do_con_write(struct tty_struct *tty, const u8 *buf, int count) return count; console_lock(); - vc = tty->driver_data; - if (vc == NULL) { - pr_err("vt: argh, driver_data is NULL !\n"); - console_unlock(); - return 0; - } - currcons = vc->vc_num; if (!vc_cons_allocated(currcons)) { /* could this happen? */ @@ -3312,16 +3302,13 @@ static void con_start(struct tty_struct *tty) static void con_flush_chars(struct tty_struct *tty) { - struct vc_data *vc; + struct vc_data *vc = tty->driver_data; if (in_interrupt()) /* from flush_to_ldisc */ return; - /* if we race with con_close(), vt may be null */ console_lock(); - vc = tty->driver_data; - if (vc) - set_cursor(vc); + set_cursor(vc); console_unlock(); } From patchwork Thu Jan 18 07:57:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763878 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30A9A1F94C; Thu, 18 Jan 2024 07:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564693; cv=none; b=eu1wR/cBz432glGKP85X50WTMPi4i34Pz75ygwioutCD8jkU+mJ+12ijE9N3hWI/SmuhkMBAd1VJPai3KV5ImrtxV/HiXVcVgW68W9VvyCLLVYfjtu2r0uQ3yc2OSAQOPjlStMSA5o4tfD2IzqQQKmohiQ4/57V1t3RddhjuuG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564693; c=relaxed/simple; bh=fU5lhbNNKhE9QJg5290En/idxniF3ADSYx6DwAHG79Q=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=iDLWzJZgQZuc9gIg/p5cVF/dygtGS1M+zZjo6kZAeR8d9QVuKhd2CXqJ8CxKD+6nILhIoVvojuInHOSjZCtWEyDJNwGz4RB/pbgdqwHzmfkVARTOEDD2RVIcnR/gh36X0eZ2SHfmz1yZ8wr+jm3n5OKskAySa1N7xz7W7eJy/fs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j6jSTSFK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j6jSTSFK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70793C433F1; Thu, 18 Jan 2024 07:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564692; bh=fU5lhbNNKhE9QJg5290En/idxniF3ADSYx6DwAHG79Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j6jSTSFKdyXYvQ2xHjDhKeuNXZgLJW65KJz7evGZ3URMzEXTzXfM2mnPdbrQNT4HF ZAp4ouwq/15OO7ocilCYQ0U+ynyRk2QaFxZIhYmdHezZGENb3gU6CgTDsDmFO5ueVQ hqAjmksRFEQ4VULcpkKeWFqffXxUoK2yqMPXZmabLiLKMUbxV08Xl8OqFLZClwTFCa hqo7pNMADYZIiB/w8W1p2NlrxkZg2RrzJb9mMKCh7Jb7pvsm53V8yBQ0VmaDdUgS/2 Az5eVkEOKLBhBp0GktCe7/IiseLhgKJNVslj3pPaqVBqcng2ihFaPiXMu8OKNd0Wix DKXLg2/GkTQvg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 05/45] tty: vt: pass proper pointers from tioclinux() Date: Thu, 18 Jan 2024 08:57:16 +0100 Message-ID: <20240118075756.10541-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Pass proper types and proper pointers (the data with an offset) to the TIOCL_* handlers. So that they need not to cast or add anything to the passed pointer. This makes obvious what is passed/consumed. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/selection.c | 8 ++++---- drivers/tty/vt/vt.c | 19 ++++++++++--------- include/linux/selection.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 8967c3a0d916..e172ede235a0 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -7,7 +7,7 @@ * 'int set_selection_kernel(struct tiocl_selection *, struct tty_struct *)' * 'void clear_selection(void)' * 'int paste_selection(struct tty_struct *)' - * 'int sel_loadlut(char __user *)' + * 'int sel_loadlut(u32 __user *)' * * Now that /dev/vcs exists, most of this can disappear again. */ @@ -111,15 +111,15 @@ static inline int inword(const u32 c) /** * sel_loadlut() - load the LUT table - * @p: user table + * @lut: user table * * Load the LUT table from user space. The caller must hold the console * lock. Make a temporary copy so a partial update doesn't make a mess. */ -int sel_loadlut(char __user *p) +int sel_loadlut(u32 __user *lut) { u32 tmplut[ARRAY_SIZE(inwordLut)]; - if (copy_from_user(tmplut, (u32 __user *)(p+4), sizeof(inwordLut))) + if (copy_from_user(tmplut, lut, sizeof(inwordLut))) return -EFAULT; memcpy(inwordLut, tmplut, sizeof(inwordLut)); return 0; diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index e131edea00da..079dbff562fd 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -145,7 +145,7 @@ static void gotoxy(struct vc_data *vc, int new_x, int new_y); static void save_cur(struct vc_data *vc); static void reset_terminal(struct vc_data *vc, int do_clear); static void con_flush_chars(struct tty_struct *tty); -static int set_vesa_blanking(char __user *p); +static int set_vesa_blanking(u8 __user *mode); static void set_cursor(struct vc_data *vc); static void hide_cursor(struct vc_data *vc); static void console_callback(struct work_struct *ignored); @@ -3134,6 +3134,8 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) { char type, data; char __user *p = (char __user *)arg; + void __user *param_aligned32 = (u32 __user *)arg + 1; + void __user *param = (void __user *)arg + 1; int lines; int ret; @@ -3147,8 +3149,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) case TIOCL_SETSEL: if (!capable(CAP_SYS_ADMIN)) return -EPERM; - return set_selection_user((struct tiocl_selection - __user *)(p+1), tty); + return set_selection_user(param, tty); case TIOCL_PASTESEL: if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -3162,7 +3163,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) if (!capable(CAP_SYS_ADMIN)) return -EPERM; console_lock(); - ret = sel_loadlut(p); + ret = sel_loadlut(param_aligned32); console_unlock(); break; case TIOCL_GETSHIFTSTATE: @@ -3181,7 +3182,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) return put_user(data, p); case TIOCL_SETVESABLANK: console_lock(); - ret = set_vesa_blanking(p); + ret = set_vesa_blanking(param); console_unlock(); break; case TIOCL_GETKMSGREDIRECT: @@ -3204,7 +3205,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) */ return fg_console; case TIOCL_SCROLLCONSOLE: - if (get_user(lines, (s32 __user *)(p+4))) + if (get_user(lines, (s32 __user *)param_aligned32)) return -EFAULT; /* @@ -4262,11 +4263,11 @@ postcore_initcall(vtconsole_class_init); * Screen blanking */ -static int set_vesa_blanking(char __user *p) +static int set_vesa_blanking(u8 __user *mode_user) { - unsigned int mode; + u8 mode; - if (get_user(mode, p + 1)) + if (get_user(mode, mode_user)) return -EFAULT; vesa_blank_mode = (mode < 4) ? mode : 0; diff --git a/include/linux/selection.h b/include/linux/selection.h index 170ef28ff26b..b7cd23e56a2b 100644 --- a/include/linux/selection.h +++ b/include/linux/selection.h @@ -20,7 +20,7 @@ extern int set_selection_user(const struct tiocl_selection __user *sel, extern int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty); extern int paste_selection(struct tty_struct *tty); -extern int sel_loadlut(char __user *p); +extern int sel_loadlut(u32 __user *lut); extern int mouse_reporting(void); extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry); From patchwork Thu Jan 18 07:57:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765113 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DEB8200BC; Thu, 18 Jan 2024 07:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564694; cv=none; b=o52os+/DOYdtPNoBLcdcZcqaqgvGDmZ5ETTVAkbEwid1HH+39mLF7onLVXZs2+DLiUoXb+bMpu12EsAxTZx1FbUDQJVrH2MUfcVnqaVrPTzOLBPDXgvkF3iZLhZ14JuyZaXNkSaJ8DDTJVrStE2F1w8nHzJAust4JwdPoQteuzc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564694; c=relaxed/simple; bh=KLUOMz+nCtQ37yc2nhuHZ5rCdOgRh78LalfH38bE/Io=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=hH/2SHCC3FaVS0KMQj24HF4gWhld4jPrjX8sY/dXUgN9UIS8qqJ+d2al3PhDB8aTKKc91ADi4QB6nWQ674TSisba5XGFLk/aaD8mOVRYQQDZNfTmYKqPIKfxmsITxMLVg+I6aBsPjOMZXKvVZqJEhzeVNKiY7BTOAjWqesIpt7M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HE1F+swH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HE1F+swH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23FB6C43390; Thu, 18 Jan 2024 07:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564694; bh=KLUOMz+nCtQ37yc2nhuHZ5rCdOgRh78LalfH38bE/Io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HE1F+swHwiEmOCOhxTxLu2VE+QOVFM6l9dW6E/T8BexybVd0VlBk5+p2ZBBghCWte uSr04nOoKyWd6wrHupsx/TKng89u6jJ4YfTwWM9Yx1yAqseL2N97bycflrMdMGKaLm MC1FVA0LIoGja1Y8LfQKO7XuRxOxYZq1aCkeXx2mnYOCCkp3aC15Ag2MwkJ1kCJRBB ARvdbMdtDHzy7a1v3AEm8UR2a7WqZ7Awxv534eE5CA20llt2NgSuX9LKS6MtNEABFl eMKbt2MXO/kIbwm1ct/ya+tHYPledlhfDzn7K/ETgLh2BnTq1voYn8+QPnQ8QAStAD ZvyGhzhehD2LA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 06/45] tty: vt: push console lock from tioclinux() down to 2 functions Date: Thu, 18 Jan 2024 08:57:17 +0100 Message-ID: <20240118075756.10541-7-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Avoid costly user copies under the console lock. So push the lock down from tioclinux() to sel_loadlut() and set_vesa_blanking(). It is now obvious what is actually protected. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/selection.c | 11 +++++++++-- drivers/tty/vt/vt.c | 13 +++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index e172ede235a0..91d789c025c6 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -113,15 +113,22 @@ static inline int inword(const u32 c) * sel_loadlut() - load the LUT table * @lut: user table * - * Load the LUT table from user space. The caller must hold the console - * lock. Make a temporary copy so a partial update doesn't make a mess. + * Load the LUT table from user space. Make a temporary copy so a partial + * update doesn't make a mess. + * + * Locking: The console lock is acquired. */ int sel_loadlut(u32 __user *lut) { u32 tmplut[ARRAY_SIZE(inwordLut)]; + if (copy_from_user(tmplut, lut, sizeof(inwordLut))) return -EFAULT; + + console_lock(); memcpy(inwordLut, tmplut, sizeof(inwordLut)); + console_unlock(); + return 0; } diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 079dbff562fd..3a6f60ad2224 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3162,10 +3162,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) case TIOCL_SELLOADLUT: if (!capable(CAP_SYS_ADMIN)) return -EPERM; - console_lock(); - ret = sel_loadlut(param_aligned32); - console_unlock(); - break; + return sel_loadlut(param_aligned32); case TIOCL_GETSHIFTSTATE: /* * Make it possible to react to Shift+Mousebutton. Note that @@ -3181,10 +3178,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) console_unlock(); return put_user(data, p); case TIOCL_SETVESABLANK: - console_lock(); - ret = set_vesa_blanking(param); - console_unlock(); - break; + return set_vesa_blanking(param); case TIOCL_GETKMSGREDIRECT: data = vt_get_kmsg_redirect(); return put_user(data, p); @@ -4270,7 +4264,10 @@ static int set_vesa_blanking(u8 __user *mode_user) if (get_user(mode, mode_user)) return -EFAULT; + console_lock(); vesa_blank_mode = (mode < 4) ? mode : 0; + console_unlock(); + return 0; } From patchwork Thu Jan 18 07:57:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763877 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 057BE20B02; Thu, 18 Jan 2024 07:58:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564697; cv=none; b=Ids3QFz++Ss2nJGN5JqGLVwLpytz5KHn/mOX/vyVGpO5YnnzQ/WubRXrRiPOFFevmFEIRvBvGBJS7YklZgcqwKZtUe/4d1tmIOah/EjH+f9jEgWoRpyEbn4OJYDI55ZCdZ/CTwzgtHlgOXuvxTJWhHqlnbhX6GlVmxJzsCPSy2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564697; c=relaxed/simple; bh=mbeOO3/wQG7zrKVPovwISN/Vz9cG62FT4cGebtEkkis=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=U61vyv2Aqj+aTYf+BY1SCLLWVEX3/7eg8AUWlBGcQkeO/HkuIOnMHl6srVirUI2USzjiKXn67iSEcsMpnOZfSU90qwWegCZNMxzo3aIjnHKtVBRWRFW+sk2xKXpUgoydgraDxUBgBAJW8CjZeXxkMJ+sYQL22MtUaBfFoEgZsh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XTbag7YB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XTbag7YB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE636C433C7; Thu, 18 Jan 2024 07:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564696; bh=mbeOO3/wQG7zrKVPovwISN/Vz9cG62FT4cGebtEkkis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTbag7YBqGjCwTW+176Jq0TjK2obwi+nI5fQdEK4uTeXw/EBow9TOHTV328C6pw7t NRKY7iM9ZWOOJyLAXbWW0IAvW6TIr7NBNQb8i4cc0oyy7WnfeY+RxhcAheZGGC0hpJ iZJOPB6z4FB/Eu5268MRDhy2vbSWuvNfgmHKFbQAGc/E6yMabr+aPlYr8oOFNuD8qb ZLs3bpPvyNM/kI2+lPLJXYy7zuhkH3UUM9xZpGv6lh82w82P8QdwSp7SFCpkLC0DPs ocbK4QBlXC84NNO2aw4dY56XYSCGp+dlTH6Ag2G9IMnzjdSSloJiGO08WktGxtp1MB Hrzw5bvMFa76Q== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 07/45] tty: vt: pass vc_resize_user as a parameter Date: Thu, 18 Jan 2024 08:57:18 +0100 Message-ID: <20240118075756.10541-8-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It is pretty unfortunate to set vc_data::vc_resize_user in two callers of vc_do_resize(). vc_resize_user is immediately reset there (while remembering it). So instead of this back and forth, pass 'from_user' as a parameter. Notes on 'int user': * The name changes from 'user' to 'from_user' on some places to be consistent. * The type is bool now as 'int user' might evoke user's uid or whatever. Provided vc_resize() is called on many places and they need not to care about this parameter, its prototype is kept unchanged. Instead, it is now an inline calling a new __vc_resize() which implements the above. This patch makes the situation much more obvious. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/tty/vt/vt.c | 28 +++++++++++++--------------- drivers/tty/vt/vt_ioctl.c | 6 ++---- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 2 +- include/linux/console_struct.h | 1 - include/linux/vt_kern.h | 9 ++++++++- 7 files changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 3a6f60ad2224..c87837306074 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1115,13 +1115,13 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ } static inline int resize_screen(struct vc_data *vc, int width, int height, - int user) + bool from_user) { /* Resizes the resolution of the display adapater */ int err = 0; if (vc->vc_sw->con_resize) - err = vc->vc_sw->con_resize(vc, width, height, user); + err = vc->vc_sw->con_resize(vc, width, height, from_user); return err; } @@ -1132,6 +1132,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, * @vc: virtual console private data * @cols: columns * @lines: lines + * @from_user: invoked by a user? * * Resize a virtual console, clipping according to the actual constraints. * If the caller passes a tty structure then update the termios winsize @@ -1142,21 +1143,17 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, */ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, - unsigned int cols, unsigned int lines) + unsigned int cols, unsigned int lines, bool from_user) { unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; unsigned long end; unsigned int old_rows, old_row_size, first_copied_row; unsigned int new_cols, new_rows, new_row_size, new_screen_size; - unsigned int user; unsigned short *oldscreen, *newscreen; u32 **new_uniscr = NULL; WARN_CONSOLE_UNLOCKED(); - user = vc->vc_resize_user; - vc->vc_resize_user = 0; - if (cols > VC_MAXCOL || lines > VC_MAXROW) return -EINVAL; @@ -1182,7 +1179,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, * to deal with possible errors from the code below, we call * the resize_screen here as well. */ - return resize_screen(vc, new_cols, new_rows, user); + return resize_screen(vc, new_cols, new_rows, from_user); } if (new_screen_size > KMALLOC_MAX_SIZE || !new_screen_size) @@ -1205,7 +1202,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, old_rows = vc->vc_rows; old_row_size = vc->vc_size_row; - err = resize_screen(vc, new_cols, new_rows, user); + err = resize_screen(vc, new_cols, new_rows, from_user); if (err) { kfree(newscreen); vc_uniscr_free(new_uniscr); @@ -1292,22 +1289,23 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, } /** - * vc_resize - resize a VT + * __vc_resize - resize a VT * @vc: virtual console * @cols: columns * @rows: rows + * @from_user: invoked by a user? * * Resize a virtual console as seen from the console end of things. We * use the common vc_do_resize methods to update the structures. The * caller must hold the console sem to protect console internals and * vc->port.tty */ - -int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) +int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows, + bool from_user) { - return vc_do_resize(vc->port.tty, vc, cols, rows); + return vc_do_resize(vc->port.tty, vc, cols, rows, from_user); } -EXPORT_SYMBOL(vc_resize); +EXPORT_SYMBOL(__vc_resize); /** * vt_resize - resize a VT @@ -1327,7 +1325,7 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws) int ret; console_lock(); - ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); + ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row, false); console_unlock(); return ret; } diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c index 8c685b501404..4b91072f3a4e 100644 --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -714,8 +714,7 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs) vcp->vc_scan_lines = v.v_vlin; if (v.v_clin) vcp->vc_cell_height = v.v_clin; - vcp->vc_resize_user = 1; - ret = vc_resize(vcp, v.v_cols, v.v_rows); + ret = __vc_resize(vcp, v.v_cols, v.v_rows, true); if (ret) { vcp->vc_scan_lines = save_scan_lines; vcp->vc_cell_height = save_cell_height; @@ -923,9 +922,8 @@ int vt_ioctl(struct tty_struct *tty, vc = vc_cons[i].d; if (vc) { - vc->vc_resize_user = 1; /* FIXME: review v tty lock */ - vc_resize(vc_cons[i].d, cc, ll); + __vc_resize(vc_cons[i].d, cc, ll, true); } } console_unlock(); diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 9176fff9ce6e..0c76e2817b49 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1081,12 +1081,12 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font, unsigne } static int vgacon_resize(struct vc_data *c, unsigned int width, - unsigned int height, unsigned int user) + unsigned int height, bool from_user) { if ((width << 1) * height > vga_vram_size) return -EINVAL; - if (user) { + if (from_user) { /* * Ho ho! Someone (svgatextmode, eh?) may have reprogrammed * the video mode! Set the new defaults then and go away. diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index a8c32cb4c878..dd2f4617485c 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1996,7 +1996,7 @@ static void updatescrollmode(struct fbcon_display *p, #define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */ static int fbcon_resize(struct vc_data *vc, unsigned int width, - unsigned int height, unsigned int user) + unsigned int height, bool from_user) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; diff --git a/include/linux/console.h b/include/linux/console.h index 779d388af8a0..38b379d6c624 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -66,7 +66,7 @@ struct consw { int (*con_font_default)(struct vc_data *vc, struct console_font *font, char *name); int (*con_resize)(struct vc_data *vc, unsigned int width, - unsigned int height, unsigned int user); + unsigned int height, bool from_user); void (*con_set_palette)(struct vc_data *vc, const unsigned char *table); void (*con_scrolldelta)(struct vc_data *vc, int lines); diff --git a/include/linux/console_struct.h b/include/linux/console_struct.h index 539f1cd45309..20f564e98552 100644 --- a/include/linux/console_struct.h +++ b/include/linux/console_struct.h @@ -151,7 +151,6 @@ struct vc_data { DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */ unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */ unsigned short * vc_translate; - unsigned int vc_resize_user; /* resize request from user */ unsigned int vc_bell_pitch; /* Console bell pitch */ unsigned int vc_bell_duration; /* Console bell duration */ unsigned short vc_cur_blink_ms; /* Cursor blink duration */ diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h index a789ea3ed2a0..d008c3d0a9bb 100644 --- a/include/linux/vt_kern.h +++ b/include/linux/vt_kern.h @@ -25,7 +25,8 @@ extern int fg_console, last_console, want_console; int vc_allocate(unsigned int console); int vc_cons_allocated(unsigned int console); -int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines); +int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines, + bool from_user); struct vc_data *vc_deallocate(unsigned int console); void reset_palette(struct vc_data *vc); void do_blank_screen(int entering_gfx); @@ -42,6 +43,12 @@ void redraw_screen(struct vc_data *vc, int is_switch); #define update_screen(x) redraw_screen(x, 0) #define switch_screen(x) redraw_screen(x, 1) +static inline int vc_resize(struct vc_data *vc, unsigned int cols, + unsigned int lines) +{ + return __vc_resize(vc, cols, lines, false); +} + struct tty_struct; int tioclinux(struct tty_struct *tty, unsigned long arg); From patchwork Thu Jan 18 07:57:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765112 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD77820B1B; Thu, 18 Jan 2024 07:58:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564698; cv=none; b=iMKg9Ji6k8thZyqvsBa48W+h72EVJel2y5iyZI8NegWAvgkmCSSrr5tRhCkyxajyCITWMl5B3y+qC1rngeOQvUFGakjgM8JOQug/ytd4I6A1l96m36Ionu9npj4V5oFJmZm+nZLHqEpfSyM+HIpuL4mrvQv6NJnirOsRywZStyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564698; c=relaxed/simple; bh=NurnY/n3MIEH+3Fog1rQ9f+5l/LwSVWrvTynpHmGqrk=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=EO0Ga7NHRAa9l25+uSyTykM02fUTZAWG+J8ks78RsjqygCLld/FJq8411F4RoRua6xRBCxFKpiSmch9+y1mbI0T6L0XogzkLM08YGtOdSULS9ITSMn0k52L9BsHk/Mr+sw2EktPltC92+DPYXERZAdlLWz3N6aoW5dbUk6TGXxU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QTrWph8k; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QTrWph8k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56CBAC433C7; Thu, 18 Jan 2024 07:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564698; bh=NurnY/n3MIEH+3Fog1rQ9f+5l/LwSVWrvTynpHmGqrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTrWph8kxlXCEl0PNiUQ+8nzl8VC1/+BTUhxVyqof9IU+7f4kOb20rjKiLgq1Idgk 2z6+ck6vQDGhSg88rzt2PZAX7GqlKeTUH4pzP0+vzJ54Q7p/h82N2PM92i54B8KdQW r1TtbQU4lxHRekpLmwcr9mYL4jwXs/1eE23Ngb2TxlbW2hmWL+0Q4SDGe2ry+JDvl7 lIsvUfOLS0kpsrte41ew0zbsukI3q4Md8PJHzivZlVCSiwsSGQd7oqUhywvpwMmFAz KB6urOcZ2sl+oDsIxQI4oRss7/9Ic+54iC2QKzpDte0rAmz0FK2XYznSJGzUA4R8xi fdumJOCEeGoHg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 08/45] tty: vt: make vc_is_sel()'s vc const Date: Thu, 18 Jan 2024 08:57:19 +0100 Message-ID: <20240118075756.10541-9-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's only an aid to people reading the header and/or calling vc_is_sel(). vc is only tested there, so having it const makes sense. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/selection.c | 2 +- include/linux/selection.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 91d789c025c6..34ee09f5a8f4 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -88,7 +88,7 @@ void clear_selection(void) } EXPORT_SYMBOL_GPL(clear_selection); -bool vc_is_sel(struct vc_data *vc) +bool vc_is_sel(const struct vc_data *vc) { return vc == vc_sel.cons; } diff --git a/include/linux/selection.h b/include/linux/selection.h index b7cd23e56a2b..533509f6ba4f 100644 --- a/include/linux/selection.h +++ b/include/linux/selection.h @@ -24,7 +24,7 @@ extern int sel_loadlut(u32 __user *lut); extern int mouse_reporting(void); extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry); -bool vc_is_sel(struct vc_data *vc); +bool vc_is_sel(const struct vc_data *vc); extern int console_blanked; From patchwork Thu Jan 18 07:57:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763876 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C66702209E; Thu, 18 Jan 2024 07:58:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564700; cv=none; b=fE5qAv1EIQh0Ej2YJcARniEgDeSfPkaFnnKpJDfQXmwCEI6+ONVtGKm0B7pJLPV8iSoozSdL5oH1iaftH8vkPEdnXnPCzPzLOAagKKLk24Y66J0J4zSKEbayXme+F71+/XtlqrHtj3IiuLX4B44POEnBot/q0AgkIp3Xh+EB0sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564700; c=relaxed/simple; bh=wjvcMWVgxrLbYPn/W5a6My3T4c3HUQqRmsrqTj7fe3U=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=UUoZxStuQHcSJInT0UYamTQQV3WkhWxcMyiIyn+d31pBHt3G5ri9WAoi+efHUnhX55p4e2FlUXoHG3FOx87X+vFVMlfaYF0fo7reFUdqr0JMjBzs3vZgXcRE7JOXliZegM2cg25ZScgUmJHyMp15TIBspdBSmCuTN8tF1+2bErY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Qb+RdyAB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Qb+RdyAB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AB1DC433C7; Thu, 18 Jan 2024 07:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564700; bh=wjvcMWVgxrLbYPn/W5a6My3T4c3HUQqRmsrqTj7fe3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qb+RdyABSiZLH+Z2VZwL68sS+8QBI/TgBBHmGIvFIBzf+6Oem3YtGEUYUGXWk3Ocm iVCPkj0VQeS7ALeKmnSpZQzHZ/hWR86v5HT+iaXQ821IwOjYmBV7+AN4NdL3c+caWS 4PHoDUjPCtElNjMPECrDqaBj8MrP22IjhJzi9x3/9egby97z/hWEbdoErjt6qhxhtL X88nGrLBmH0uL/fnjaT5yyPQPrY+eVPxbWcnxWszeXn8wmcVghGV8YrZxE20rxv5CZ 1bj+xZbd5mn0Nj9+53YrfyUwmReXiNEwHgQw3/m8qZrfPY3ArbYmiqOqKs/xtx7fSH WDfV3TIaBqlCw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 09/45] tty: vt: define an enum for CSI+m codes Date: Thu, 18 Jan 2024 08:57:20 +0100 Message-ID: <20240118075756.10541-10-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's always confusing to read all those case 0:, case 1: etc. in csi_* handlers. Define enum entries for all those constants in CSI+m and use them in csi_m(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 98 +++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 29 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index c87837306074..b2ba1b943eb6 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1676,6 +1676,39 @@ static int vc_t416_color(struct vc_data *vc, int i, return i; } +enum { + CSI_m_DEFAULT = 0, + CSI_m_BOLD = 1, + CSI_m_HALF_BRIGHT = 2, + CSI_m_ITALIC = 3, + CSI_m_UNDERLINE = 4, + CSI_m_BLINK = 5, + CSI_m_REVERSE = 7, + CSI_m_PRI_FONT = 10, + CSI_m_ALT_FONT1 = 11, + CSI_m_ALT_FONT2 = 12, + CSI_m_DOUBLE_UNDERLINE = 21, + CSI_m_NORMAL_INTENSITY = 22, + CSI_m_NO_ITALIC = 23, + CSI_m_NO_UNDERLINE = 24, + CSI_m_NO_BLINK = 25, + CSI_m_NO_REVERSE = 27, + CSI_m_FG_COLOR_BEG = 30, + CSI_m_FG_COLOR_END = 37, + CSI_m_FG_COLOR = 38, + CSI_m_DEFAULT_FG_COLOR = 39, + CSI_m_BG_COLOR_BEG = 40, + CSI_m_BG_COLOR_END = 47, + CSI_m_BG_COLOR = 48, + CSI_m_DEFAULT_BG_COLOR = 49, + CSI_m_BRIGHT_FG_COLOR_BEG = 90, + CSI_m_BRIGHT_FG_COLOR_END = 97, + CSI_m_BRIGHT_FG_COLOR_OFF = CSI_m_BRIGHT_FG_COLOR_BEG - CSI_m_FG_COLOR_BEG, + CSI_m_BRIGHT_BG_COLOR_BEG = 100, + CSI_m_BRIGHT_BG_COLOR_END = 107, + CSI_m_BRIGHT_BG_COLOR_OFF = CSI_m_BRIGHT_BG_COLOR_BEG - CSI_m_BG_COLOR_BEG, +}; + /* console_lock is held */ static void csi_m(struct vc_data *vc) { @@ -1683,33 +1716,33 @@ static void csi_m(struct vc_data *vc) for (i = 0; i <= vc->vc_npar; i++) switch (vc->vc_par[i]) { - case 0: /* all attributes off */ + case CSI_m_DEFAULT: /* all attributes off */ default_attr(vc); break; - case 1: + case CSI_m_BOLD: vc->state.intensity = VCI_BOLD; break; - case 2: + case CSI_m_HALF_BRIGHT: vc->state.intensity = VCI_HALF_BRIGHT; break; - case 3: + case CSI_m_ITALIC: vc->state.italic = true; break; - case 21: + case CSI_m_DOUBLE_UNDERLINE: /* * No console drivers support double underline, so * convert it to a single underline. */ - case 4: + case CSI_m_UNDERLINE: vc->state.underline = true; break; - case 5: + case CSI_m_BLINK: vc->state.blink = true; break; - case 7: + case CSI_m_REVERSE: vc->state.reverse = true; break; - case 10: /* ANSI X3.64-1979 (SCO-ish?) + case CSI_m_PRI_FONT: /* ANSI X3.64-1979 (SCO-ish?) * Select primary font, don't display control chars if * defined, don't set bit 8 on output. */ @@ -1717,7 +1750,7 @@ static void csi_m(struct vc_data *vc) vc->vc_disp_ctrl = 0; vc->vc_toggle_meta = 0; break; - case 11: /* ANSI X3.64-1979 (SCO-ish?) + case CSI_m_ALT_FONT1: /* ANSI X3.64-1979 (SCO-ish?) * Select first alternate font, lets chars < 32 be * displayed as ROM chars. */ @@ -1725,7 +1758,7 @@ static void csi_m(struct vc_data *vc) vc->vc_disp_ctrl = 1; vc->vc_toggle_meta = 0; break; - case 12: /* ANSI X3.64-1979 (SCO-ish?) + case CSI_m_ALT_FONT2: /* ANSI X3.64-1979 (SCO-ish?) * Select second alternate font, toggle high bit * before displaying as ROM char. */ @@ -1733,47 +1766,54 @@ static void csi_m(struct vc_data *vc) vc->vc_disp_ctrl = 1; vc->vc_toggle_meta = 1; break; - case 22: + case CSI_m_NORMAL_INTENSITY: vc->state.intensity = VCI_NORMAL; break; - case 23: + case CSI_m_NO_ITALIC: vc->state.italic = false; break; - case 24: + case CSI_m_NO_UNDERLINE: vc->state.underline = false; break; - case 25: + case CSI_m_NO_BLINK: vc->state.blink = false; break; - case 27: + case CSI_m_NO_REVERSE: vc->state.reverse = false; break; - case 38: + case CSI_m_FG_COLOR: i = vc_t416_color(vc, i, rgb_foreground); break; - case 48: + case CSI_m_BG_COLOR: i = vc_t416_color(vc, i, rgb_background); break; - case 39: + case CSI_m_DEFAULT_FG_COLOR: vc->state.color = (vc->vc_def_color & 0x0f) | (vc->state.color & 0xf0); break; - case 49: + case CSI_m_DEFAULT_BG_COLOR: vc->state.color = (vc->vc_def_color & 0xf0) | (vc->state.color & 0x0f); break; default: - if (vc->vc_par[i] >= 90 && vc->vc_par[i] <= 107) { - if (vc->vc_par[i] < 100) + if (vc->vc_par[i] >= CSI_m_BRIGHT_FG_COLOR_BEG && + vc->vc_par[i] <= CSI_m_BRIGHT_BG_COLOR_END) { + if (vc->vc_par[i] < CSI_m_BRIGHT_BG_COLOR_BEG) vc->state.intensity = VCI_BOLD; - vc->vc_par[i] -= 60; + vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; } - if (vc->vc_par[i] >= 30 && vc->vc_par[i] <= 37) - vc->state.color = color_table[vc->vc_par[i] - 30] - | (vc->state.color & 0xf0); - else if (vc->vc_par[i] >= 40 && vc->vc_par[i] <= 47) - vc->state.color = (color_table[vc->vc_par[i] - 40] << 4) - | (vc->state.color & 0x0f); + if (vc->vc_par[i] >= CSI_m_FG_COLOR_BEG && + vc->vc_par[i] <= CSI_m_FG_COLOR_END) { + vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; + vc->state.color = color_table[vc->vc_par[i]] | + (vc->state.color & 0xf0); + } else if (vc->vc_par[i] >= CSI_m_BG_COLOR_BEG && + vc->vc_par[i] <= CSI_m_BG_COLOR_END) { + vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; + vc->state.color = (color_table[vc->vc_par[i]] << 4) | + (vc->state.color & 0x0f); + } + break; } update_attr(vc); From patchwork Thu Jan 18 07:57:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765111 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 65AD122613; Thu, 18 Jan 2024 07:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564702; cv=none; b=Z/mO8/rJYTYKZEzl3dQDuUFq/gBiYi0eduJjpsBKZ07ZixqwYZVi0VQrMJSfEpBA5rbjelcc8GVntiIso0A6Rm4WkTViAqohAtE9GOc+Ju1pHscDo/YoEazkP+ZQCN/085xhndqn9jsRoMqfszNB1mqdWkO9ROrkbWc2NSR0SWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564702; c=relaxed/simple; bh=0shcMcCLihadWi/wJYrSetusFI9blXYLuPpY44fMuL0=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=P17/EPtMRUc3N4zeh981KZJ81QoIaW4e6PqRSFcAbWWwN5fgMk5PN8Wk5mIHXPmVE3lvdkV0h5aPV431AVcOr3Wf3PWdkAPMChP1TKX0AJ4X6c6F5bLuUasvG4E1OHfuFFIcQLyh2Y9TV/tG4Cx98mWpYirW/0xoNRYyxf65Qqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d9VnJe6v; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d9VnJe6v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2A4DC43390; Thu, 18 Jan 2024 07:58:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564701; bh=0shcMcCLihadWi/wJYrSetusFI9blXYLuPpY44fMuL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9VnJe6v7SeJt/NlQu66AciIFlDw3KGpN3/60g5asVanDT5tXuJDk+GLZPdCPj56V PyNdZWQbjG8spYth3iCH2Sy17BdK7uj4OqZIidGX9NXaaEzdYYuJmVv1hTQet3uxx6 gd6YqwE4ZpGBXL58Ig9gEYjIcAResloI1RcdDSLMnbt0dEm74cdKKMi5PUee6I4R0E SPdwDmGtYXLZE6IAtvFhcq6rmlZ6m7r18PriwUC3/T0GN4yzjP7ehtOGGCIpOoUE8J BG/yuTlre2hIjhTeztgI06Gx9sG0r8zjXz7HI5+EG+iLkvVpKXN0yi9kCu+CvXqEZG JyoIISJ8d3nEw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 10/45] tty: vt: use case ranges for CSI+m fg/bg colors Date: Thu, 18 Jan 2024 08:57:21 +0100 Message-ID: <20240118075756.10541-11-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replacing the default case with the iffery by case ranges makes the code more understandable at last. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index b2ba1b943eb6..66ebc90a9fe9 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1795,25 +1795,22 @@ static void csi_m(struct vc_data *vc) vc->state.color = (vc->vc_def_color & 0xf0) | (vc->state.color & 0x0f); break; - default: - if (vc->vc_par[i] >= CSI_m_BRIGHT_FG_COLOR_BEG && - vc->vc_par[i] <= CSI_m_BRIGHT_BG_COLOR_END) { - if (vc->vc_par[i] < CSI_m_BRIGHT_BG_COLOR_BEG) - vc->state.intensity = VCI_BOLD; - vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; - } - if (vc->vc_par[i] >= CSI_m_FG_COLOR_BEG && - vc->vc_par[i] <= CSI_m_FG_COLOR_END) { - vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; - vc->state.color = color_table[vc->vc_par[i]] | - (vc->state.color & 0xf0); - } else if (vc->vc_par[i] >= CSI_m_BG_COLOR_BEG && - vc->vc_par[i] <= CSI_m_BG_COLOR_END) { - vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; - vc->state.color = (color_table[vc->vc_par[i]] << 4) | - (vc->state.color & 0x0f); - } - + case CSI_m_BRIGHT_FG_COLOR_BEG ... CSI_m_BRIGHT_FG_COLOR_END: + vc->state.intensity = VCI_BOLD; + vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF; + fallthrough; + case CSI_m_FG_COLOR_BEG ... CSI_m_FG_COLOR_END: + vc->vc_par[i] -= CSI_m_FG_COLOR_BEG; + vc->state.color = color_table[vc->vc_par[i]] | + (vc->state.color & 0xf0); + break; + case CSI_m_BRIGHT_BG_COLOR_BEG ... CSI_m_BRIGHT_BG_COLOR_END: + vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF; + fallthrough; + case CSI_m_BG_COLOR_BEG ... CSI_m_BG_COLOR_END: + vc->vc_par[i] -= CSI_m_BG_COLOR_BEG; + vc->state.color = (color_table[vc->vc_par[i]] << 4) | + (vc->state.color & 0x0f); break; } update_attr(vc); From patchwork Thu Jan 18 07:57:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763875 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDEE924B36; Thu, 18 Jan 2024 07:58:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564703; cv=none; b=LqUx7IhPAA3/lcxSceqEKKZmTeT1aSuyf8Db6Cw+do9VxHCMJL9aYgxWgKYWAMqm0PsLtBvPP5wVVNSHMtmJPzjOeq565XhB5OdmikaUBw7xddxoJva0uX84/T0FFbD+IrPXXQMZigmvw9+RofZj7vXT19nkN3RbBgw1h5bj4n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564703; c=relaxed/simple; bh=inEZdPNYb4mBWCDk6mN9TwUiu3T0fjhmaqQyXC/6bwA=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=q8i94Izr926xTBi+iYl956VX2tlCrpjkdqNxxaopJmFrOki8RBUHXe6+OtalKN348WDlcSLYZZk+WqYfPlwLWGBvaWPHU5Hdtip+ZL0LVyXhiV6i7AUD5YBm0QbU1KWPZtibTIXjC4+3JuUmYsvh24CSJuy+Hg2GFXy9rJ+tliI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RUcyj+aZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RUcyj+aZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66358C43399; Thu, 18 Jan 2024 07:58:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564703; bh=inEZdPNYb4mBWCDk6mN9TwUiu3T0fjhmaqQyXC/6bwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RUcyj+aZugJbjQqqpmDfarOXYhfqXPPLZOTIKDk1c4kC4a09L67sHqpZHzUozJT7D TY1LAcOSAe8aH8SkMyVhWLlvOpeGi79OqJkpKi+qKukDLoM0bpd+EbZ90YzeBvHjYJ jB3Eitw65/6GfDO2PstZ+2WSYL5QfYx9UuCfEPxSJVdXXn872Z2PW4L3wE0TxlnHeS ysFf7oiFDiuXJP4CPzB7FiWb1Xk0PCu/DbdaYdmTFyyAQh4tYb3V1fnatervM+VYJf 6THLq4fdSstdzhKqbILjZVBCrf9eorAv0eo3D1u09vR4qlKTgdk8xdQXRVJEKtQPdS fFbwrqbQJyFNA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 11/45] tty: vt: define an enum for CSI+J codes Date: Thu, 18 Jan 2024 08:57:22 +0100 Message-ID: <20240118075756.10541-12-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Decrypt the constant values by proper enum names. This time in csi_J(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 66ebc90a9fe9..4f7831f81db6 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1498,13 +1498,20 @@ static inline void del(struct vc_data *vc) /* ignored */ } +enum { + CSI_J_CURSOR_TO_END = 0, + CSI_J_START_TO_CURSOR = 1, + CSI_J_VISIBLE = 2, + CSI_J_FULL = 3, +}; + static void csi_J(struct vc_data *vc, int vpar) { unsigned int count; unsigned short * start; switch (vpar) { - case 0: /* erase from cursor to end of display */ + case CSI_J_CURSOR_TO_END: vc_uniscr_clear_line(vc, vc->state.x, vc->vc_cols - vc->state.x); vc_uniscr_clear_lines(vc, vc->state.y + 1, @@ -1512,16 +1519,16 @@ static void csi_J(struct vc_data *vc, int vpar) count = (vc->vc_scr_end - vc->vc_pos) >> 1; start = (unsigned short *)vc->vc_pos; break; - case 1: /* erase from start to cursor */ + case CSI_J_START_TO_CURSOR: vc_uniscr_clear_line(vc, 0, vc->state.x + 1); vc_uniscr_clear_lines(vc, 0, vc->state.y); count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; start = (unsigned short *)vc->vc_origin; break; - case 3: /* include scrollback */ + case CSI_J_FULL: flush_scrollback(vc); fallthrough; - case 2: /* erase whole display */ + case CSI_J_VISIBLE: vc_uniscr_clear_lines(vc, 0, vc->vc_rows); count = vc->vc_cols * vc->vc_rows; start = (unsigned short *)vc->vc_origin; From patchwork Thu Jan 18 07:57:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765110 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53EDC2575C; Thu, 18 Jan 2024 07:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564706; cv=none; b=PxMzHGTDraHOxoO/aT98VIGzppZLS0kLj8X76yidIBCCrflUw+H3etXz8hYYa+LKDfzmsbWdSqvy93JwuBiZC4x/TcGtZ/fD5oKQXCN1rIOWBBc6FXEVpKDD7VryuX/9B6U6nZnkVTnFrOuhdBPRlh86s3LbjltuC2u85UJY/1U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564706; c=relaxed/simple; bh=QRYobT/Ntnc2Q+TR1Sf0nMM7PfTjMjX2jtpPvm5til4=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=WV5iQu5SfyXaYKEIj4fhTz+5Jsv7+GPsrgXauEtsMX5sYFM3wVba5yh3VRGIDZJiviLcpcG/a3IcU69IWfhfx7ZfY9om2uMTHtEF0HnYpNm6itFJ6l0vMflZkY+5yTHORieiJiJ42ywc1JSsu98LACu6Ok0PjlYPHBkDhpJZBxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DH/8RpQ6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DH/8RpQ6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AD15C433F1; Thu, 18 Jan 2024 07:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564705; bh=QRYobT/Ntnc2Q+TR1Sf0nMM7PfTjMjX2jtpPvm5til4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DH/8RpQ6P0bni7Ix6C1TZiX9PgzPgAEm5EGhjBJMYmAEfnEUUotzqq3BuXc6vRvSZ 8Jlu5hG5+gvnJ57EkVddMW/UprITM1++eFvATQ2MpKU02LB/LyWf7uSmZwOUaMQ0Tf 3IDRogfHAHUr8sB7jR3wdlPmFyspdwIwN/oM4VEz6du1oHKwQnyz8QMkSN6DprcmzA sWuSuNga1Qy2BI/TOOKmh92OAvZkde4XiTTEvs2r0d4EvLr1T57GV4PNEcu/+1Vl6T dgKfyKqTXrEDYEevmf8CFAdWj7yRfvakDEHLJtZpeFsPIKQleDjZWR+teKsH0QRtbm gpYgiMv7a/fWw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 12/45] tty: vt: reflow csi_J() Date: Thu, 18 Jan 2024 08:57:23 +0100 Message-ID: <20240118075756.10541-13-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Push cases one level left, according to coding style. And reorder local variables. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 4f7831f81db6..22ef7366c155 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1507,34 +1507,34 @@ enum { static void csi_J(struct vc_data *vc, int vpar) { + unsigned short *start; unsigned int count; - unsigned short * start; switch (vpar) { - case CSI_J_CURSOR_TO_END: - vc_uniscr_clear_line(vc, vc->state.x, - vc->vc_cols - vc->state.x); - vc_uniscr_clear_lines(vc, vc->state.y + 1, - vc->vc_rows - vc->state.y - 1); - count = (vc->vc_scr_end - vc->vc_pos) >> 1; - start = (unsigned short *)vc->vc_pos; - break; - case CSI_J_START_TO_CURSOR: - vc_uniscr_clear_line(vc, 0, vc->state.x + 1); - vc_uniscr_clear_lines(vc, 0, vc->state.y); - count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; - start = (unsigned short *)vc->vc_origin; - break; - case CSI_J_FULL: - flush_scrollback(vc); - fallthrough; - case CSI_J_VISIBLE: - vc_uniscr_clear_lines(vc, 0, vc->vc_rows); - count = vc->vc_cols * vc->vc_rows; - start = (unsigned short *)vc->vc_origin; - break; - default: - return; + case CSI_J_CURSOR_TO_END: + vc_uniscr_clear_line(vc, vc->state.x, + vc->vc_cols - vc->state.x); + vc_uniscr_clear_lines(vc, vc->state.y + 1, + vc->vc_rows - vc->state.y - 1); + count = (vc->vc_scr_end - vc->vc_pos) >> 1; + start = (unsigned short *)vc->vc_pos; + break; + case CSI_J_START_TO_CURSOR: + vc_uniscr_clear_line(vc, 0, vc->state.x + 1); + vc_uniscr_clear_lines(vc, 0, vc->state.y); + count = ((vc->vc_pos - vc->vc_origin) >> 1) + 1; + start = (unsigned short *)vc->vc_origin; + break; + case CSI_J_FULL: + flush_scrollback(vc); + fallthrough; + case CSI_J_VISIBLE: + vc_uniscr_clear_lines(vc, 0, vc->vc_rows); + count = vc->vc_cols * vc->vc_rows; + start = (unsigned short *)vc->vc_origin; + break; + default: + return; } scr_memsetw(start, vc->vc_video_erase_char, 2 * count); if (con_should_update(vc)) From patchwork Thu Jan 18 07:57:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763874 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67C8025767; Thu, 18 Jan 2024 07:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564707; cv=none; b=nQhP00zaVE/32Nkz0H3wZM3ki7cfCBQNbKpkSz92w1mlhcfXEqXM1IdIsUchYlVxad6xbASh8eo/KB0Y/UuBlcsO3OBXmInc++YYi6ZW26TzSqMQCh6RV7sN66iGqJtHEdx/FqJI/Qgrp8iSLoKIbeLUgVAJpPJ05AX7gYSgUwM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564707; c=relaxed/simple; bh=xmX1GzocGEugxu/cnlcvvwjE5Bbm+09jL2ht7Rb2p+g=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=kCbPm6ukr/ZFj4ZVMf4FC4ijfAr5aE1f+Vnf1oNbHTnlM4TkvGL0ffCf2iAtcPgFyX+DWRcjX0wL7H5Ufn71OUhYNCoEUYtGiAHaiSs1ppcW+W7rg2NWgSd6N8Lchik6TcFTCgPoMQVA577g82aDKt1kGzv/bodg104fUvAi/qQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vHJi7AO1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vHJi7AO1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2C00C43390; Thu, 18 Jan 2024 07:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564707; bh=xmX1GzocGEugxu/cnlcvvwjE5Bbm+09jL2ht7Rb2p+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vHJi7AO1PNdvAsN7hDS1juOpdy9ki5ylj3fmAxuqH+AYBbTbF1FsFXF/9gdbMaSwT 1U1PjhFNjAx7ZTgbwRmrs7u8lR263THO5/wK2K7NSrqomwLoE0Q/1UU3DN76FAEqMp hkn3FyJY9I5EPye8XJ0z2C1EdGFMIYpna0B7kYZnbYNi2zfOLKvfpgtJrpvlDkBLlW 4smxs9ZspcFIOKluQwaIcYRXM4lCf53SejjCr7sjm+LGzhK9c3E/I/IwHuVbsWlNM8 QL3UH9MLnS7P938tg942WbkgoVh0cgfFTGFdy1VAqkkBCCoSps32QBYIYOlBGn55Rs /txVwh+wAeZbQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 13/45] tty: vt: define an enum for CSI+K codes Date: Thu, 18 Jan 2024 08:57:24 +0100 Message-ID: <20240118075756.10541-14-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Decrypt the constant values by proper enum names. This time in csi_K(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 22ef7366c155..3e3ec9c28f26 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1542,6 +1542,12 @@ static void csi_J(struct vc_data *vc, int vpar) vc->vc_need_wrap = 0; } +enum { + CSI_K_CURSOR_TO_LINEEND = 0, + CSI_K_LINESTART_TO_CURSOR = 1, + CSI_K_LINE = 2, +}; + static void csi_K(struct vc_data *vc, int vpar) { unsigned int count; @@ -1549,15 +1555,15 @@ static void csi_K(struct vc_data *vc, int vpar) int offset; switch (vpar) { - case 0: /* erase from cursor to end of line */ + case CSI_K_CURSOR_TO_LINEEND: offset = 0; count = vc->vc_cols - vc->state.x; break; - case 1: /* erase from start of line to cursor */ + case CSI_K_LINESTART_TO_CURSOR: offset = -vc->state.x; count = vc->state.x + 1; break; - case 2: /* erase whole line */ + case CSI_K_LINE: offset = -vc->state.x; count = vc->vc_cols; break; From patchwork Thu Jan 18 07:57:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765109 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE398286B2; Thu, 18 Jan 2024 07:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564708; cv=none; b=YAD8X3gA9Bk6NjCVpFsp49tSIN6+ml3TknmFnuo48ODfnS8Ro2LSfrCJ9sfbXxCsJKCrC5f2QJi19Q5d5LtlPIyHm0cShpcaoPLNdYcHtQdYv7mWzpwa6WU1vorYru9+i5H7jhkapGJHeRhKq/g+QFzgsiW2Fh270szDOG7aRIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564708; c=relaxed/simple; bh=3Td1/Et6XB0SeL2/aGZuKKdWG7Y3VJzO4iDAmw63Qkk=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=GokVi0Y+Lr/qDQnJB5HfGoAi/cPKs90cDuC7Z2RxcjIHVeU+PpnqrNLrQqScIPRFNR4PhHaPtDfMlNLUgtMZBL73e/OpnvfIUBk/WzFHRWmp19lkHJLzkxtNYQvvkv+DmQQAsxnPBI4o7eo3Z4F9VvURq6tSbd2xG9pSNlxA9v8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gleT+uLL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gleT+uLL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76D43C433F1; Thu, 18 Jan 2024 07:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564708; bh=3Td1/Et6XB0SeL2/aGZuKKdWG7Y3VJzO4iDAmw63Qkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gleT+uLL8njaXC4xkeYX1B7ODOEnrZ2r+9l5Fm72lrvGcv3R76mLM68LsBGgrxHrS 900Z47O6GX44pmdRiSPqHTy4ef7pHkRvbQwlbAFbbNMHXaPVbz4Q3yNuiqG2HovzF1 lP1GKJIwICFUIeyqTLeCO8zc3cbS9OA2c1rt21xKNt8vtOJYXzr5BG8EN1/8oqIgKK e7HsU3HheBNTM1QqEmdGNq6+HBY4DvfJag7B/Aw0hUqe5djnjnzLr+TjVFFGXK964d oFGYyA9ukJP3QN3MmxtcC/T0AnAj7p3VwxhawmIE2aR9/9boND/JMRjgVvLyQZ/rG7 hIEukecWSZ4wA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 14/45] tty: vt: reflow csi_K() Date: Thu, 18 Jan 2024 08:57:25 +0100 Message-ID: <20240118075756.10541-15-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Push cases one level left, according to coding style. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 3e3ec9c28f26..c00c568c11a5 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1555,20 +1555,20 @@ static void csi_K(struct vc_data *vc, int vpar) int offset; switch (vpar) { - case CSI_K_CURSOR_TO_LINEEND: - offset = 0; - count = vc->vc_cols - vc->state.x; - break; - case CSI_K_LINESTART_TO_CURSOR: - offset = -vc->state.x; - count = vc->state.x + 1; - break; - case CSI_K_LINE: - offset = -vc->state.x; - count = vc->vc_cols; - break; - default: - return; + case CSI_K_CURSOR_TO_LINEEND: + offset = 0; + count = vc->vc_cols - vc->state.x; + break; + case CSI_K_LINESTART_TO_CURSOR: + offset = -vc->state.x; + count = vc->state.x + 1; + break; + case CSI_K_LINE: + offset = -vc->state.x; + count = vc->vc_cols; + break; + default: + return; } vc_uniscr_clear_line(vc, vc->state.x + offset, count); scr_memsetw(start + offset, vc->vc_video_erase_char, 2 * count); From patchwork Thu Jan 18 07:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763873 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6336728DCC; Thu, 18 Jan 2024 07:58:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564711; cv=none; b=ow4ltEgwI6nEuKRE0qudEszIjTJLtlLX0MS08zByL5H7F6AP/hbxzI4pCyJ8gejQcHC9qMCd6OYAdJ0/hWsmtJmtY3sNaE4N3BQ7IoKzgt+S8l67kxGIp+3/QDT6Pbin37uQ14qQIkUchrg7Q25Md1OEfuOOHPUnBHOjD7ZsGKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564711; c=relaxed/simple; bh=zvbWFLhlZqiTKCZrUNu1Xqw8wgSMHRcmoYbp1pvidpA=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=WO5Lmq6hYBDkzZYgM4GJqr1ec5/ZUmwi2d/DKMl4ek6mql/AyMX7JMnpuFZ3yL+JBS3NxfYz0UGhNe6W/XRRqaP2ISAx9KYETyfEvbUVxjy6tzux4d6diPNJhY9aDdIYKVLMcQEdK4cvGmzdpAcdURBBGF4NtZiiK+4e+KsxT28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rmAS91dP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rmAS91dP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B85EC43394; Thu, 18 Jan 2024 07:58:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564710; bh=zvbWFLhlZqiTKCZrUNu1Xqw8wgSMHRcmoYbp1pvidpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rmAS91dPHhyNlQBbnmbElCsP+mlesFSo6sZNH6OWFBmt7u0gCUOyDc2Yh0dVxa3PU wx60ZzRIJKPcUYocCj+WtMg7WiRz5+MOubUafopRWxaeLafwjwrWUdhnz1rtwi3HJU QwU5KTpRo4aLLwOGrtzO19QEjJEtcuqfPflk02CIj9Z1HDjiQn5hIk/T3XgCPBOzqo fsxFZxPH4n1fWfIv42I7Mh3nWbAVdLrGC+MtxNN5LOlwhSV3QV/V2ieNvnV85UrajX K0EjFh2/L83zWxFiUIgfZjEoxoZ6pyJp13Cs+hP3AKk9gQ5y85s0NnM7HocSD4A/Mt rLSVC6zuLi29Q== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 15/45] tty: vt: pass vpar as unsigned to csi_J() and csi_K() Date: Thu, 18 Jan 2024 08:57:26 +0100 Message-ID: <20240118075756.10541-16-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 vc_data::vc_par is passed to these function and that is unsigned. So accept unsigned in csi_J() and csi_K(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index c00c568c11a5..4b514187ef15 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1505,7 +1505,7 @@ enum { CSI_J_FULL = 3, }; -static void csi_J(struct vc_data *vc, int vpar) +static void csi_J(struct vc_data *vc, unsigned int vpar) { unsigned short *start; unsigned int count; @@ -1548,7 +1548,7 @@ enum { CSI_K_LINE = 2, }; -static void csi_K(struct vc_data *vc, int vpar) +static void csi_K(struct vc_data *vc, unsigned int vpar) { unsigned int count; unsigned short *start = (unsigned short *)vc->vc_pos; From patchwork Thu Jan 18 07:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765108 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36C5A28DDB; Thu, 18 Jan 2024 07:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564712; cv=none; b=f3y4KByAecWQpdc4aHqjiEuYyOd3MnoS/ne16/370Tb6udwbesDVfGK1paS1vUiL1yL0lcCwXG6+IB5b63mAf6/0gxvuPF/KH220vHigLCn0BUvKF6+VK8jT9u/xRpd6QSLSGohOJEMY4qQGGbu+JlRzDGHrh0RZpwrk9NI8jOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564712; c=relaxed/simple; bh=jneHPzOwrZgSk7jv5sxyALGkZSuZbXyrgWxzBqQrqFs=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=VLT8dA5NXuxRdWYy9iQhRsOfd/CFA6mu1Y2SWSw/reo18Tolm9MoSQgHbrAIKR0eGSvi1pbNcJo+p8s5voMMTWMYPksK6kZu7Dh8HvDsMa7sc86as1wCj2eD8ynttPjZpVf8YdD/6gEUpLFlxQMi9fQdrMZCMXZbmK5NgQtJvE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dZmt5D9d; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dZmt5D9d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D36EEC433B2; Thu, 18 Jan 2024 07:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564712; bh=jneHPzOwrZgSk7jv5sxyALGkZSuZbXyrgWxzBqQrqFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZmt5D9dYiMPCcxEvRJlvZyH7BZTZiz2MoMTQyYP/zx2lWrHO4PiGrXjBvjg9lsTG Zz+QrXWeSJ2mNDZBF/OFwjiFPTCTEJohwzKA6yTywBjt5piVWYgx0XI5U628E4iUU6 ZniAl8ewU2H0kON+ozczmPw65HfC/t2XlYlzWzcnsmL3F7To2eSX+etCtTSU4c9iyZ UsMS1rHHrywT2plq9hwYt17Gh4Rk23O2Tk9b7PVg0p0Q+QUtymlJgZJls7nKUJ/Noc A1mVilOiNvnF3cyqGfrrTbfKSSrCGxvqrhdBj1v1+8Bj1Be+gLDdREDw3Ief5C3I/b vqzU3pPVb53Aw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 16/45] tty: vt: define an enum for ascii characters Date: Thu, 18 Jan 2024 08:57:27 +0100 Message-ID: <20240118075756.10541-17-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 I didn't find definitions for ascii in the kernel yet, so define it for non-printable characters used here. Note we use ' ' instead of 32 on one line too. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 62 ++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 4b514187ef15..7006889c920d 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2157,6 +2157,28 @@ static bool ansi_control_string(unsigned int state) return false; } +enum { + ASCII_NULL = 0, + ASCII_BELL = 7, + ASCII_BACKSPACE = 8, + ASCII_IGNORE_FIRST = ASCII_BACKSPACE, + ASCII_HTAB = 9, + ASCII_LINEFEED = 10, + ASCII_VTAB = 11, + ASCII_FORMFEED = 12, + ASCII_CAR_RET = 13, + ASCII_IGNORE_LAST = ASCII_CAR_RET, + ASCII_SHIFTOUT = 14, + ASCII_SHIFTIN = 15, + ASCII_CANCEL = 24, + ASCII_SUBSTITUTE = 26, + ASCII_ESCAPE = 27, + ASCII_CSI_IGNORE_FIRST = ' ', /* 0x2x, 0x3a and 0x3c - 0x3f */ + ASCII_CSI_IGNORE_LAST = '?', + ASCII_DEL = 127, + ASCII_EXT_CSI = 128 + ASCII_ESCAPE, +}; + /* console_lock is held */ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) { @@ -2164,21 +2186,22 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) * Control characters can be used in the _middle_ * of an escape sequence, aside from ANSI control strings. */ - if (ansi_control_string(vc->vc_state) && c >= 8 && c <= 13) + if (ansi_control_string(vc->vc_state) && c >= ASCII_IGNORE_FIRST && + c <= ASCII_IGNORE_LAST) return; switch (c) { - case 0: + case ASCII_NULL: return; - case 7: + case ASCII_BELL: if (ansi_control_string(vc->vc_state)) vc->vc_state = ESnormal; else if (vc->vc_bell_duration) kd_mksound(vc->vc_bell_pitch, vc->vc_bell_duration); return; - case 8: + case ASCII_BACKSPACE: bs(vc); return; - case 9: + case ASCII_HTAB: vc->vc_pos -= (vc->state.x << 1); vc->state.x = find_next_bit(vc->vc_tab_stop, @@ -2190,34 +2213,37 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_pos += (vc->state.x << 1); notify_write(vc, '\t'); return; - case 10: case 11: case 12: + case ASCII_LINEFEED: + case ASCII_VTAB: + case ASCII_FORMFEED: lf(vc); if (!is_kbd(vc, lnm)) return; fallthrough; - case 13: + case ASCII_CAR_RET: cr(vc); return; - case 14: + case ASCII_SHIFTOUT: vc->state.charset = 1; vc->vc_translate = set_translate(vc->state.Gx_charset[1], vc); vc->vc_disp_ctrl = 1; return; - case 15: + case ASCII_SHIFTIN: vc->state.charset = 0; vc->vc_translate = set_translate(vc->state.Gx_charset[0], vc); vc->vc_disp_ctrl = 0; return; - case 24: case 26: + case ASCII_CANCEL: + case ASCII_SUBSTITUTE: vc->vc_state = ESnormal; return; - case 27: + case ASCII_ESCAPE: vc->vc_state = ESesc; return; - case 127: + case ASCII_DEL: del(vc); return; - case 128+27: + case ASCII_EXT_CSI: vc->vc_state = ESsquare; return; } @@ -2352,7 +2378,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_par[vc->vc_npar] += c - '0'; return; } - if (c >= 0x20 && c <= 0x3f) { /* 0x2x, 0x3a and 0x3c - 0x3f */ + if (c >= ASCII_CSI_IGNORE_FIRST && c <= ASCII_CSI_IGNORE_LAST) { vc->vc_state = EScsiignore; return; } @@ -2514,7 +2540,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) } return; case EScsiignore: - if (c >= 0x20 && c <= 0x3f) + if (c >= ASCII_CSI_IGNORE_FIRST && c <= ASCII_CSI_IGNORE_LAST) return; vc->vc_state = ESnormal; return; @@ -2775,17 +2801,17 @@ static bool vc_is_control(struct vc_data *vc, int tc, int c) * useless without them; to display an arbitrary font position use the * direct-to-font zone in UTF-8 mode. */ - if (c < 32) { + if (c < ' ') { if (vc->vc_disp_ctrl) return CTRL_ALWAYS & BIT(c); else return vc->vc_utf || (CTRL_ACTION & BIT(c)); } - if (c == 127 && !vc->vc_disp_ctrl) + if (c == ASCII_DEL && !vc->vc_disp_ctrl) return true; - if (c == 128 + 27) + if (c == ASCII_EXT_CSI) return true; return false; From patchwork Thu Jan 18 07:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763872 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E22A628E25; Thu, 18 Jan 2024 07:58:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564714; cv=none; b=i2ywWyT1ANk01dplGQ5nChLmRVzwXC18DIwkmKT11U6UAEmaxmvfygo7pNOHlQoL2IgCR9AQpUMuI3Vt2UgybTXDhQvn8Hx4GMaMW+ZmiGTj39FaaBhrapeAPA00HdC3FfRhg/dRADSHTuj22hsEsV4zDyOBS2jZaKE1HtjQT6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564714; c=relaxed/simple; bh=pgGIPZEv6XKRoBjxEYNP5d5VFoktwTyHpvsavE6t6hw=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=qLlXVsLdGFHbRrpTKk5jausoDSmzrzyYG/0h4VgBZA4kKs9A5x2H96EWBWS2vyflRyDoYXidBFH8RrnuLBVBJj6F5mdlk8+Tp92Ai87VlasbFYsTENvBArOF5cLiAUKbNjWuoD7Gi+dH6JHtA1MI9y7+KAtxMgxqUSSRH+SMc1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fPKaUkcf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fPKaUkcf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86DC7C433C7; Thu, 18 Jan 2024 07:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564713; bh=pgGIPZEv6XKRoBjxEYNP5d5VFoktwTyHpvsavE6t6hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPKaUkcfw6LypUl2/lKpHaTq1Z1YtNqbyudbrae5rfyAD9SvB3Uv5iX5i4y3cVPaA Ivnj4GRSdRCbsBz6QURCpzkVHXRlSecKgkSrUfkGNOgHS1Vbbrbz7rkJhzszdXGoZf 8i+gJt7aF1QUBrGx4FnaDUmqDEq58+xyTgv2Pwx7kyj/HIeeYw8jFVrHwsIU0IhLQm Lajyhnsk6FvAn5/Cj9IvwDBu8TXvxXKDFIi5E7Ekequ1zJx9s47byk5TqOZrJD9X7F RpvZgBgXVDMTAIax0neR3Cd2VByG3oFaEwr6Mf499qg4jvqbncsBfUvAeP/WEbsNxL hXDzk/P3NLh0w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 17/45] tty: vt: remove extern from functions in selection.h Date: Thu, 18 Jan 2024 08:57:28 +0100 Message-ID: <20240118075756.10541-18-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Remove unneeded 'extern' keyword from function prototypes in selection.h. This makes it more readable as no more wrapping is needed on many places. Signed-off-by: Jiri Slaby (SUSE) --- include/linux/selection.h | 52 ++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/include/linux/selection.h b/include/linux/selection.h index 533509f6ba4f..bab7d30d3446 100644 --- a/include/linux/selection.h +++ b/include/linux/selection.h @@ -14,15 +14,14 @@ struct tty_struct; struct vc_data; -extern void clear_selection(void); -extern int set_selection_user(const struct tiocl_selection __user *sel, - struct tty_struct *tty); -extern int set_selection_kernel(struct tiocl_selection *v, - struct tty_struct *tty); -extern int paste_selection(struct tty_struct *tty); -extern int sel_loadlut(u32 __user *lut); -extern int mouse_reporting(void); -extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry); +void clear_selection(void); +int set_selection_user(const struct tiocl_selection __user *sel, + struct tty_struct *tty); +int set_selection_kernel(struct tiocl_selection *v, struct tty_struct *tty); +int paste_selection(struct tty_struct *tty); +int sel_loadlut(u32 __user *lut); +int mouse_reporting(void); +void mouse_report(struct tty_struct *tty, int butt, int mrx, int mry); bool vc_is_sel(const struct vc_data *vc); @@ -33,24 +32,21 @@ extern unsigned char default_red[]; extern unsigned char default_grn[]; extern unsigned char default_blu[]; -extern unsigned short *screen_pos(const struct vc_data *vc, int w_offset, - bool viewed); -extern u16 screen_glyph(const struct vc_data *vc, int offset); -extern u32 screen_glyph_unicode(const struct vc_data *vc, int offset); -extern void complement_pos(struct vc_data *vc, int offset); -extern void invert_screen(struct vc_data *vc, int offset, int count, bool viewed); - -extern void getconsxy(const struct vc_data *vc, unsigned char xy[static 2]); -extern void putconsxy(struct vc_data *vc, unsigned char xy[static const 2]); - -extern u16 vcs_scr_readw(const struct vc_data *vc, const u16 *org); -extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org); -extern void vcs_scr_updated(struct vc_data *vc); - -extern int vc_uniscr_check(struct vc_data *vc); -extern void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, - bool viewed, - unsigned int row, unsigned int col, - unsigned int nr); +unsigned short *screen_pos(const struct vc_data *vc, int w_offset, bool viewed); +u16 screen_glyph(const struct vc_data *vc, int offset); +u32 screen_glyph_unicode(const struct vc_data *vc, int offset); +void complement_pos(struct vc_data *vc, int offset); +void invert_screen(struct vc_data *vc, int offset, int count, bool viewed); + +void getconsxy(const struct vc_data *vc, unsigned char xy[static 2]); +void putconsxy(struct vc_data *vc, unsigned char xy[static const 2]); + +u16 vcs_scr_readw(const struct vc_data *vc, const u16 *org); +void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org); +void vcs_scr_updated(struct vc_data *vc); + +int vc_uniscr_check(struct vc_data *vc); +void vc_uniscr_copy_line(const struct vc_data *vc, void *dest, bool viewed, + unsigned int row, unsigned int col, unsigned int nr); #endif From patchwork Thu Jan 18 07:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765107 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67C9F29429; Thu, 18 Jan 2024 07:58:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564716; cv=none; b=FnhwBxEVFqOHmlQLRgWS2P3W9XLw2zXEKebt4t4dBC0FznSVw96Fe0WCrc3dspDovcy1qSep81WAh7s9+An7UGGEdORUIY3ML4zKREZ7K0gC0/uYbPTdXfjeXOas9ePsUqe+dVIF02FOSuV4Tjc4KioWXReXKJi/Mp8v7sfOD1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564716; c=relaxed/simple; bh=GJfteWjzTxl1GHc/MnJTrogtTSYg1Ifld3S8+ciqzdU=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=gbsPcZL8gFyfyOv2FjCzlyIs1SoQVYFzN3TYOcwD0nXIuHFiJPGkbEH0v5tiZrZfomd3nowb0t3zjc5I5DWMM3MIh6QOlUvqt2G9F/ZKE4+Idw8MLUS0s+NQOHNR1ecEX4H8OOcNTaWG3rfMaQY3PA7SzlNQC9IqeaWyYxaFOGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uF6c4QLy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uF6c4QLy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3ED95C433C7; Thu, 18 Jan 2024 07:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564716; bh=GJfteWjzTxl1GHc/MnJTrogtTSYg1Ifld3S8+ciqzdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uF6c4QLy8e2Q+pq51ouFyq1TAWfULUPNKgdDuPJnZiSkDAlbyPJtqCczsOtTQIcWq Xwk23Q0H/G1yH3+rwV8jMDK324IwSmeAkwDNcnLnBXup8smQfjYCczenoIBvyS5ug/ opWyJB9SjEBWNgvb91KtU8zUErt6hrCDklP/3u6jUy/pGqwDuzAbr/NL1Z3kksxQ9h 0mCqIvBdCLJyyQKrhZ8BtvlsVnBh56B2qm8M5VcRcPuTL57t3WqbEnU5+e52foE23C ZjvXANOinKIjQWZjZcLx1dQpPuVkk1HCs7XpsauJSFdEchxLcjtZ20IkI3cng4UpSO zhnUetiiNW6bg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Daniel Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 18/45] tty: vt: make consw::con_debug_*() return void Date: Thu, 18 Jan 2024 08:57:29 +0100 Message-ID: <20240118075756.10541-19-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The return value of con_debug_enter() and con_debug_leave() is ignored on many fronts. So just don't propagate errors (the current implementations return 0 anyway) and make the return type a void. Signed-off-by: Jiri Slaby (SUSE) Cc: Daniel Vetter Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/tty/vt/vt.c | 21 ++++----------------- drivers/video/fbdev/core/fbcon.c | 6 ++---- include/linux/console.h | 18 ++++++------------ 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 7006889c920d..a953c3f262a5 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4026,15 +4026,9 @@ EXPORT_SYMBOL(con_is_visible); * Called when the console is taken over by the kernel debugger, this * function needs to save the current console state, then put the console * into a state suitable for the kernel debugger. - * - * RETURNS: - * Zero on success, nonzero if a failure occurred when trying to prepare - * the console for the debugger. */ -int con_debug_enter(struct vc_data *vc) +void con_debug_enter(struct vc_data *vc) { - int ret = 0; - saved_fg_console = fg_console; saved_last_console = last_console; saved_want_console = want_console; @@ -4043,7 +4037,7 @@ int con_debug_enter(struct vc_data *vc) vc->vc_mode = KD_TEXT; console_blanked = 0; if (vc->vc_sw->con_debug_enter) - ret = vc->vc_sw->con_debug_enter(vc); + vc->vc_sw->con_debug_enter(vc); #ifdef CONFIG_KGDB_KDB /* Set the initial LINES variable if it is not already set */ if (vc->vc_rows < 999) { @@ -4073,7 +4067,6 @@ int con_debug_enter(struct vc_data *vc) } } #endif /* CONFIG_KGDB_KDB */ - return ret; } EXPORT_SYMBOL_GPL(con_debug_enter); @@ -4082,15 +4075,10 @@ EXPORT_SYMBOL_GPL(con_debug_enter); * * Restore the console state to what it was before the kernel debugger * was invoked. - * - * RETURNS: - * Zero on success, nonzero if a failure occurred when trying to restore - * the console. */ -int con_debug_leave(void) +void con_debug_leave(void) { struct vc_data *vc; - int ret = 0; fg_console = saved_fg_console; last_console = saved_last_console; @@ -4100,8 +4088,7 @@ int con_debug_leave(void) vc = vc_cons[fg_console].d; if (vc->vc_sw->con_debug_leave) - ret = vc->vc_sw->con_debug_leave(vc); - return ret; + vc->vc_sw->con_debug_leave(vc); } EXPORT_SYMBOL_GPL(con_debug_leave); diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index dd2f4617485c..d3fb98084eda 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2243,7 +2243,7 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) return 0; } -static int fbcon_debug_enter(struct vc_data *vc) +static void fbcon_debug_enter(struct vc_data *vc) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; @@ -2253,10 +2253,9 @@ static int fbcon_debug_enter(struct vc_data *vc) if (info->fbops->fb_debug_enter) info->fbops->fb_debug_enter(info); fbcon_set_palette(vc, color_table); - return 0; } -static int fbcon_debug_leave(struct vc_data *vc) +static void fbcon_debug_leave(struct vc_data *vc) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; @@ -2264,7 +2263,6 @@ static int fbcon_debug_leave(struct vc_data *vc) ops->graphics = ops->save_graphics; if (info->fbops->fb_debug_leave) info->fbops->fb_debug_leave(info); - return 0; } static int fbcon_get_font(struct vc_data *vc, struct console_font *font, unsigned int vpitch) diff --git a/include/linux/console.h b/include/linux/console.h index 38b379d6c624..93a1db5bf3b5 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -88,11 +88,11 @@ struct consw { * limited to, unblanking the console, loading an appropriate * palette, and allowing debugger generated output. */ - int (*con_debug_enter)(struct vc_data *vc); + void (*con_debug_enter)(struct vc_data *vc); /* * Restore the console to its pre-debug state as closely as possible. */ - int (*con_debug_leave)(struct vc_data *vc); + void (*con_debug_leave)(struct vc_data *vc); }; extern const struct consw *conswitchp; @@ -113,17 +113,11 @@ int do_unregister_con_driver(const struct consw *csw); int do_take_over_console(const struct consw *sw, int first, int last, int deflt); void give_up_console(const struct consw *sw); #ifdef CONFIG_HW_CONSOLE -int con_debug_enter(struct vc_data *vc); -int con_debug_leave(void); +void con_debug_enter(struct vc_data *vc); +void con_debug_leave(void); #else -static inline int con_debug_enter(struct vc_data *vc) -{ - return 0; -} -static inline int con_debug_leave(void) -{ - return 0; -} +static inline void con_debug_enter(struct vc_data *vc) { } +static inline void con_debug_leave(void) { } #endif /* cursor */ From patchwork Thu Jan 18 07:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763871 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A966D2A1D8; Thu, 18 Jan 2024 07:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564719; cv=none; b=c6B74wFTBazN9Is7CQHUDrgm3evhTdpLayPULfQHsAswVmzF4zWy8aiX2A9MEnC1yQpXKCVT1dGrNLEJnUvVi6ugckQkfEdMNaT8RzXmtAi7jbiO8kIBtpXhki7fP1zr8wPZ8f9lSW9GT9SkBJ1T6WfnejGFLE3UrIwEBJ4xpww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564719; c=relaxed/simple; bh=ruW08xm7jMrBAHGzRNp+myzItXRS+fMN96GkzDA9WZs=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=Qc3qyurNPaWpzGOojo4TpwtBck/hlNVs5mQapS9PyKXoIEP/SNPRSvd/Z5FxHMrN/x2sWmqrcf63pdAC52e+ihEC6FSrN3MeSo41QSW9pRBv4ri/kO+PJziIOytqVQzV7+LXJq2hO41/yETHBv79zPtL1IX9ZJ+khfRub4BtI+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wq1Z+n03; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wq1Z+n03" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAC3DC43394; Thu, 18 Jan 2024 07:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564719; bh=ruW08xm7jMrBAHGzRNp+myzItXRS+fMN96GkzDA9WZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wq1Z+n03j2pUG1JBctlxmejhwSWs4TfkeSc/TZ57gZceKFO/oWaQJW8RsVDEZhNDi re+232FEDgiFodZJyK7zAD8T66gFRApisATAVKpcQIdrLQimmORiXzI6FEcdLZEYqw 90QwXXPhjnIIqGb8p3NTfCHL78YRqamMtWTtCRTUxvEgRsITjIZBT/HA6gfmdg4Lma Ef6qm/lpOq/SPDbGrXhWieU0F/QbwU3JCvSv1oboFuw8yRrAU+m+RoYlLxHAY166Xw fQ4XDwgwjbosf0ITi5fbxESvteJfm+NUzoaSY4So4FYrOun5MUq7lCuuDaUGztO3v0 otES0uAZJ5IZg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 19/45] tty: vt: make init parameter of consw::con_init() a bool Date: Thu, 18 Jan 2024 08:57:30 +0100 Message-ID: <20240118075756.10541-20-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The 'init' parameter of consw::con_init() is true for the first call of the hook on a particular console. So make the parameter a bool. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org Reviewed-by: Geert Uytterhoeven --- drivers/tty/vt/vt.c | 8 ++++---- drivers/video/console/dummycon.c | 2 +- drivers/video/console/mdacon.c | 2 +- drivers/video/console/newport_con.c | 2 +- drivers/video/console/sticon.c | 2 +- drivers/video/console/vgacon.c | 2 +- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 4 +++- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index a953c3f262a5..eada45683594 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -999,7 +999,7 @@ int vc_cons_allocated(unsigned int i) return (i < MAX_NR_CONSOLES && vc_cons[i].d); } -static void visual_init(struct vc_data *vc, int num, int init) +static void visual_init(struct vc_data *vc, int num, bool init) { /* ++Geert: vc->vc_sw->con_init determines console size */ if (vc->vc_sw) @@ -1083,7 +1083,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */ vc->port.ops = &vc_port_ops; INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); - visual_init(vc, currcons, 1); + visual_init(vc, currcons, true); if (!*vc->uni_pagedict_loc) con_set_default_unimap(vc); @@ -3527,7 +3527,7 @@ static int __init con_init(void) vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT); INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK); tty_port_init(&vc->port); - visual_init(vc, currcons, 1); + visual_init(vc, currcons, true); /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); vc_init(vc, currcons || !vc->vc_sw->con_save_screen); @@ -3696,7 +3696,7 @@ static int do_bind_con_driver(const struct consw *csw, int first, int last, old_was_color = vc->vc_can_do_color; vc->vc_sw->con_deinit(vc); vc->vc_origin = (unsigned long)vc->vc_screenbuf; - visual_init(vc, i, 0); + visual_init(vc, i, false); set_origin(vc); update_attr(vc); diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 14af5d9e13b0..f2cef9d9a4b5 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -98,7 +98,7 @@ static const char *dummycon_startup(void) return "dummy device"; } -static void dummycon_init(struct vc_data *vc, int init) +static void dummycon_init(struct vc_data *vc, bool init) { vc->vc_can_do_color = 1; if (init) { diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index ef29b321967f..c5b255c96879 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -352,7 +352,7 @@ static const char *mdacon_startup(void) return "MDA-2"; } -static void mdacon_init(struct vc_data *c, int init) +static void mdacon_init(struct vc_data *c, bool init) { c->vc_complement_mask = 0x0800; /* reverse video */ c->vc_display_fg = &mda_display_fg; diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index e8e4f82cd4a1..12c64ef47087 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -324,7 +324,7 @@ static const char *newport_startup(void) return NULL; } -static void newport_init(struct vc_data *vc, int init) +static void newport_init(struct vc_data *vc, bool init) { int cols, rows; diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 992a4fa431aa..0bfeabc3f7c7 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -273,7 +273,7 @@ static int sticon_font_set(struct vc_data *vc, struct console_font *font, return sticon_set_font(vc, font, vpitch); } -static void sticon_init(struct vc_data *c, int init) +static void sticon_init(struct vc_data *c, bool init) { struct sti_struct *sti = sticon_sti; int vc_cols, vc_rows; diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 0c76e2817b49..2c0a952ee51a 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -367,7 +367,7 @@ static const char *vgacon_startup(void) return display_desc; } -static void vgacon_init(struct vc_data *c, int init) +static void vgacon_init(struct vc_data *c, bool init) { struct uni_pagedict *p; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index d3fb98084eda..939c5d893dfb 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -988,7 +988,7 @@ static const char *fbcon_startup(void) return display_desc; } -static void fbcon_init(struct vc_data *vc, int init) +static void fbcon_init(struct vc_data *vc, bool init) { struct fb_info *info; struct fbcon_ops *ops; diff --git a/include/linux/console.h b/include/linux/console.h index 93a1db5bf3b5..fc9450e0c78f 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -36,6 +36,8 @@ enum vc_intensity; /** * struct consw - callbacks for consoles * + * @con_init: initialize the console on @vc. @init is true for the very first + * call on this @vc. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. @@ -46,7 +48,7 @@ enum vc_intensity; struct consw { struct module *owner; const char *(*con_startup)(void); - void (*con_init)(struct vc_data *vc, int init); + void (*con_init)(struct vc_data *vc, bool init); void (*con_deinit)(struct vc_data *vc); void (*con_clear)(struct vc_data *vc, int sy, int sx, int height, int width); From patchwork Thu Jan 18 07:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765106 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44AED2C19C; Thu, 18 Jan 2024 07:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564722; cv=none; b=LRwDDHsJzqR6yGtJrOPdDJormR3dwujZPu/acLJSWhgx6S4vl4VXk87CjSyGC42gZSRIoAZKVdQoGVb5S3GBEC1jGob3GTosAm8mV+bytHfOoh39IG+hqrTMqNmO250pyyajVqZn9L8Zy8F4kelGO99/LJBOfS5+EIqarfQsQOU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564722; c=relaxed/simple; bh=c0C04f0WNfAoHiv9OyXKYqjGnILRz9IsgB4B1d0rIHM=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=Rxi5NuW1tX7s6MTLmCkfKIm2u0dlDkQbQADbSIGE/QFPjOwUnfllfErz5IlH8vKm0NTnbiDunIryIegg3fKSbvPREDRfKjK5RqPhW0LFAQT4ek9gxnKQnoXBUKbZ9D9U9ZeX5mXywzpMBQ25vcmdQyySvEg2s9qs7XUfkLXCp4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pIuE/OEl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pIuE/OEl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A70CCC433F1; Thu, 18 Jan 2024 07:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564722; bh=c0C04f0WNfAoHiv9OyXKYqjGnILRz9IsgB4B1d0rIHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIuE/OElPNvx251HduzBz8jvLlCUl997apYXlZlYCzHSFLycXrD0maXiQfwoBV45C DZNFppzD6gtKRffbSmsQoH6CPQFpCNJqf+SERMuebnZznDmhX22eaNha7i8xHdWYWd A9G1LA75w++NlSNpRffeIVXfWJc33pMRruaSyKvBA3KSnn/VX1nfZv8n5eXsi6cuPA kaSVZKzhkvvX0TzAiaEX2X6fzJVhVHqQCZ2Glg8rrcaH8igMxMyikjHCz2f5akqoaN xIV2dbkCLXMZkwUBP9fJWxAFsbAv6qSLPQH+aC6poWdiRG0eSjKcMKtm8TlP5fyW/3 aMTjSCnKUZgHA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 20/45] tty: vt: sanitize arguments of consw::con_clear() Date: Thu, 18 Jan 2024 08:57:31 +0100 Message-ID: <20240118075756.10541-21-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In consw::con_clear(): * Height is always 1, so drop it. * Offsets and width are always unsigned values, so re-type them as such. This needs a new __fbcon_clear() in the fbcon code to still handle height which might not be 1 when called internally. Note that tests for negative count/width are left in place -- they are taken care of in the next patches. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/tty/vt/vt.c | 2 +- drivers/video/console/dummycon.c | 4 ++-- drivers/video/console/mdacon.c | 15 +++++--------- drivers/video/console/newport_con.c | 6 +++--- drivers/video/console/sticon.c | 8 ++++---- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 32 +++++++++++++++++------------ include/linux/console.h | 5 +++-- 8 files changed, 39 insertions(+), 37 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index eada45683594..a4ee983824d5 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1590,7 +1590,7 @@ static void csi_X(struct vc_data *vc, unsigned int vpar) vc_uniscr_clear_line(vc, vc->state.x, count); scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count); if (con_should_update(vc)) - vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count); + vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count); vc->vc_need_wrap = 0; } diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index f2cef9d9a4b5..0a69d5c216ee 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -109,8 +109,8 @@ static void dummycon_init(struct vc_data *vc, bool init) } static void dummycon_deinit(struct vc_data *vc) { } -static void dummycon_clear(struct vc_data *vc, int sy, int sx, int height, - int width) { } +static void dummycon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, + unsigned int width) { } static void dummycon_cursor(struct vc_data *vc, int mode) { } static bool dummycon_scroll(struct vc_data *vc, unsigned int top, diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index c5b255c96879..1ddbb6cd5b0c 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -442,23 +442,18 @@ static void mdacon_putcs(struct vc_data *c, const unsigned short *s, } } -static void mdacon_clear(struct vc_data *c, int y, int x, - int height, int width) +static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x, + unsigned int width) { u16 *dest = mda_addr(x, y); u16 eattr = mda_convert_attr(c->vc_video_erase_char); - if (width <= 0 || height <= 0) + if (width <= 0) return; - if (x==0 && width==mda_num_columns) { - scr_memsetw(dest, eattr, height*width*2); - } else { - for (; height > 0; height--, dest+=mda_num_columns) - scr_memsetw(dest, eattr, width*2); - } + scr_memsetw(dest, eattr, width * 2); } - + static int mdacon_switch(struct vc_data *c) { return 1; /* redrawing needed */ diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 12c64ef47087..55c6106b3507 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -346,12 +346,12 @@ static void newport_deinit(struct vc_data *c) } } -static void newport_clear(struct vc_data *vc, int sy, int sx, int height, - int width) +static void newport_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, + unsigned int width) { int xend = ((sx + width) << 3) - 1; int ystart = ((sy << 4) + topscan) & 0x3ff; - int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff; + int yend = (((sy + 1) << 4) + topscan - 1) & 0x3ff; if (logo_active) return; diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 0bfeabc3f7c7..d99c2a659bfd 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -300,13 +300,13 @@ static void sticon_deinit(struct vc_data *c) sticon_set_def_font(i); } -static void sticon_clear(struct vc_data *conp, int sy, int sx, int height, - int width) +static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx, + unsigned int width) { - if (!height || !width) + if (!width) return; - sti_clear(sticon_sti, sy, sx, height, width, + sti_clear(sticon_sti, sy, sx, 1, width, conp->vc_video_erase_char, font_data[conp->vc_num]); } diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 2c0a952ee51a..c6bd4acbe1d2 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1191,8 +1191,8 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, * The console `switch' structure for the VGA based console */ -static void vgacon_clear(struct vc_data *vc, int sy, int sx, int height, - int width) { } +static void vgacon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, + unsigned int width) { } static void vgacon_putc(struct vc_data *vc, int c, int ypos, int xpos) { } static void vgacon_putcs(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos) { } diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 939c5d893dfb..8a31a36483ea 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1235,8 +1235,8 @@ static void fbcon_deinit(struct vc_data *vc) * restriction is simplicity & efficiency at the moment. */ -static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, - int width) +static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, + unsigned int height, unsigned int width) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; @@ -1273,6 +1273,12 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height, ops->clear(vc, info, real_y(p, sy), sx, height, width); } +static void fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, + unsigned int width) +{ + __fbcon_clear(vc, sy, sx, 1, width); +} + static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos) { @@ -1760,7 +1766,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, case SCROLL_MOVE: fbcon_redraw_blit(vc, info, p, t, b - t - count, count); - fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + __fbcon_clear(vc, b - count, 0, count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - count)), @@ -1783,7 +1789,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_up; - fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + __fbcon_clear(vc, b - count, 0, count, vc->vc_cols); break; case SCROLL_PAN_REDRAW: @@ -1801,7 +1807,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, vc->vc_rows - b, b); } else fbcon_redraw_move(vc, p, t + count, b - t - count, t); - fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + __fbcon_clear(vc, b - count, 0, count, vc->vc_cols); break; case SCROLL_PAN_MOVE: @@ -1824,14 +1830,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_up; - fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + __fbcon_clear(vc, b - count, 0, count, vc->vc_cols); break; case SCROLL_REDRAW: redraw_up: fbcon_redraw(vc, t, b - t - count, count * vc->vc_cols); - fbcon_clear(vc, b - count, 0, count, vc->vc_cols); + __fbcon_clear(vc, b - count, 0, count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * (b - count)), @@ -1848,7 +1854,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, case SCROLL_MOVE: fbcon_redraw_blit(vc, info, p, b - 1, b - t - count, -count); - fbcon_clear(vc, t, 0, count, vc->vc_cols); + __fbcon_clear(vc, t, 0, count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * t), @@ -1871,7 +1877,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_down; - fbcon_clear(vc, t, 0, count, vc->vc_cols); + __fbcon_clear(vc, t, 0, count, vc->vc_cols); break; case SCROLL_PAN_MOVE: @@ -1893,7 +1899,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, b - t - count, vc->vc_cols); else goto redraw_down; - fbcon_clear(vc, t, 0, count, vc->vc_cols); + __fbcon_clear(vc, t, 0, count, vc->vc_cols); break; case SCROLL_PAN_REDRAW: @@ -1910,14 +1916,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, fbcon_redraw_move(vc, p, count, t, 0); } else fbcon_redraw_move(vc, p, t, b - t - count, t + count); - fbcon_clear(vc, t, 0, count, vc->vc_cols); + __fbcon_clear(vc, t, 0, count, vc->vc_cols); break; case SCROLL_REDRAW: redraw_down: fbcon_redraw(vc, b - 1, b - t - count, -count * vc->vc_cols); - fbcon_clear(vc, t, 0, count, vc->vc_cols); + __fbcon_clear(vc, t, 0, count, vc->vc_cols); scr_memsetw((unsigned short *) (vc->vc_origin + vc->vc_size_row * t), @@ -2196,7 +2202,7 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, oldc = vc->vc_video_erase_char; vc->vc_video_erase_char &= charmask; - fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols); + __fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols); vc->vc_video_erase_char = oldc; } } diff --git a/include/linux/console.h b/include/linux/console.h index fc9450e0c78f..8fd96a5fca5f 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -38,6 +38,7 @@ enum vc_intensity; * * @con_init: initialize the console on @vc. @init is true for the very first * call on this @vc. + * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. @@ -50,8 +51,8 @@ struct consw { const char *(*con_startup)(void); void (*con_init)(struct vc_data *vc, bool init); void (*con_deinit)(struct vc_data *vc); - void (*con_clear)(struct vc_data *vc, int sy, int sx, int height, - int width); + void (*con_clear)(struct vc_data *vc, unsigned int y, + unsigned int x, unsigned int count); void (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos); void (*con_putcs)(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos); From patchwork Thu Jan 18 07:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763870 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F317D2C688; Thu, 18 Jan 2024 07:58:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564725; cv=none; b=gZT4AcYwPokQdX8GnwL/1JRRrf/TCGkfprD0Tf93M5S02JTdKGCyl3aN5nRlrSMFEtJeUzNJLiaeTK5p5WIEmLF4s3u5fXEU1liEIYrIbguM+aWKyrKq2xJ16S6kfdbo83Fjo961vjZPbWy4q0TH7slggpbhxy0LO4Is1K8wbg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564725; c=relaxed/simple; bh=/HUcPJ1BjPv5GMtQ1xgKekTdrhD9fVd1hk++uDzgCqs=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=YHP1gr7+LENbaATnnsS4TlyWbO2OLQvwTdBzLLbB+6huH4xSvb1xPrw5XzNt9j2nDZspAL7wW58sMb5RRLexEnugHUJItI5AjavBydA+DjtAjycGrbbrw4SkjwgNbK6QwcbTEY2O99DVDeQoLAYYSUWMFdzLet+VYqj7Vuw87vE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FXWNLegc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FXWNLegc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 945FDC43399; Thu, 18 Jan 2024 07:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564724; bh=/HUcPJ1BjPv5GMtQ1xgKekTdrhD9fVd1hk++uDzgCqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXWNLegctp3Fhf2lVHyLbqQ/aJ29ru/jxnBhXLxcUeG3r4JMtYk9j4xfNlYHd+92T TGuL3YICbbpazTOXJvANDqXxsOoEmi2aoiU4SeRjhQA9T3QW9Zru/VJUiaU12dXqmW z9zZ/WP7i90YwaMFF/BL0ZPQVCtnXINr25NtGyN9l3wbL6wH/uazpxBY3ZftDPLN7z rnwRkY/dAv36z5XYeHWV3ZGq2MCmc9upg7uRifd4yOQMFAM0KK4PoPSnDE5LxQh7Rm LH4vI/qbrQliMRS59B2Ex0fQMih+DocftSPCivm8a/hwbWEKElqBbZUcnFZk1ZqY05 CSonq6VCBsl6w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 21/45] tty: vt: remove checks for count in consw::con_clear() implementations Date: Thu, 18 Jan 2024 08:57:32 +0100 Message-ID: <20240118075756.10541-22-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 'count' in consw::con_clear() is guaranteed to be positive. csi_X() (the only caller) takes the minimum of the vc parameter (which is at least 1) and count of characters till the end of the line. The latter is computed as a subtraction of vc->vc_cols (count) and vc->state.x (offset). So for the worst case, full line, it is 1. Therefore, there is no point in checking zero or negative values (width is now unsigned anyway). Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/video/console/mdacon.c | 3 --- drivers/video/console/sticon.c | 3 --- 2 files changed, 6 deletions(-) diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 1ddbb6cd5b0c..2ff2c9394d40 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -448,9 +448,6 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x, u16 *dest = mda_addr(x, y); u16 eattr = mda_convert_attr(c->vc_video_erase_char); - if (width <= 0) - return; - scr_memsetw(dest, eattr, width * 2); } diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index d99c2a659bfd..b1d972d9a31c 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -303,9 +303,6 @@ static void sticon_deinit(struct vc_data *c) static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx, unsigned int width) { - if (!width) - return; - sti_clear(sticon_sti, sy, sx, 1, width, conp->vc_video_erase_char, font_data[conp->vc_num]); } From patchwork Thu Jan 18 07:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765105 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 177CB2C6BF; Thu, 18 Jan 2024 07:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564727; cv=none; b=aRaLoc5kGReqUF3Rf/IW4ZCgNPDb0Hu6N44CcEc7dXCeVof4/HSz/2zbJETqFXPlEqsr75wyre+cJndHcxW31gWdlodtCWjDNE2dokgQ0If5KgvAmr3x+MPaCvNPVHxGh6P9N3kqCaQXXf0HkrNOhQHFRafa/+5VK12cwOjOxqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564727; c=relaxed/simple; bh=YRzFj4BN6f8YNzJ8WuOrgNl97sICo/Ly8ow9YGu8iDo=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=ENUzimpuHQNewtPjtDhCdRK7zeGvPPtNvuLjEvHBPPDMCUH3lGiReZG/dmcKZv2VtRIDBpBeIY/CxLloXRJqix2hgiUSK/zFDl7Yx1IkTzeQrrhL9svoWclEqbs2YhgKglM2WpzSPm8CcU5WahakQdP/+QQeLLvqGwuyJdT5gAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=miPuuFj5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="miPuuFj5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DBACC433F1; Thu, 18 Jan 2024 07:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564726; bh=YRzFj4BN6f8YNzJ8WuOrgNl97sICo/Ly8ow9YGu8iDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miPuuFj5etJVAcz9yJUXZ4WE9Q52BwEXzyJTluO6MtFeXv7WULwc+Du2fVhcYNF4T wDG8j944GJmjlV1PiFDf4gfbwkDoOEB9HnBwV8mZBTM4smbIlMdmkTIb4TUCHcLSyb DxWSTnpXlxvIFQ9v8XW8bJTOyLCtsv2d8+B7wAojkwt8Ubk9PXUxjKZFE8Y6d0NIhr RJGeljdzI0rUpvI1x4LxD7L7J8K5aHGRv4sgb8DmqbrTrXIjWDfiCd8TnkMeANnUow ZTKmf+Sesp/tLL1GsA90sj/8he8+OryJ43lgjYmLtBQHoZIu5GTOGxeohGpb5Wo+6b xcOBVUsd+g8MQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 22/45] tty: vt: add con_putc() helper Date: Thu, 18 Jan 2024 08:57:33 +0100 Message-ID: <20240118075756.10541-23-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 And let it call consw::con_putc() if it exists, otherwise consw::con_putcs(). This is similar to tty_put_char(). It supports dropping unneeded duplication of code like sticon_putc() is (see the next patch). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index a4ee983824d5..73e48a53dc31 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -300,6 +300,14 @@ static inline unsigned short *screenpos(const struct vc_data *vc, int offset, return p; } +static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x) +{ + if (vc->vc_sw->con_putc) + vc->vc_sw->con_putc(vc, ca, y, x); + else + vc->vc_sw->con_putcs(vc, &ca, 1, y, x); +} + /* Called from the keyboard irq path.. */ static inline void scrolldelta(int lines) { @@ -762,7 +770,7 @@ void complement_pos(struct vc_data *vc, int offset) old_offset < vc->vc_screenbuf_size) { scr_writew(old, screenpos(vc, old_offset, true)); if (con_should_update(vc)) - vc->vc_sw->con_putc(vc, old, oldy, oldx); + con_putc(vc, old, oldy, oldx); notify_update(vc); } @@ -779,7 +787,7 @@ void complement_pos(struct vc_data *vc, int offset) if (con_should_update(vc)) { oldx = (offset >> 1) % vc->vc_cols; oldy = (offset >> 1) / vc->vc_cols; - vc->vc_sw->con_putc(vc, new, oldy, oldx); + con_putc(vc, new, oldy, oldx); } notify_update(vc); } @@ -833,7 +841,7 @@ static void add_softcursor(struct vc_data *vc) i ^= CUR_FG; scr_writew(i, (u16 *)vc->vc_pos); if (con_should_update(vc)) - vc->vc_sw->con_putc(vc, i, vc->state.y, vc->state.x); + con_putc(vc, i, vc->state.y, vc->state.x); } static void hide_softcursor(struct vc_data *vc) @@ -841,8 +849,8 @@ static void hide_softcursor(struct vc_data *vc) if (softcursor_original != -1) { scr_writew(softcursor_original, (u16 *)vc->vc_pos); if (con_should_update(vc)) - vc->vc_sw->con_putc(vc, softcursor_original, - vc->state.y, vc->state.x); + con_putc(vc, softcursor_original, vc->state.y, + vc->state.x); softcursor_original = -1; } } From patchwork Thu Jan 18 07:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763869 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED5882C867; Thu, 18 Jan 2024 07:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564730; cv=none; b=ZkY5i5G+MVdPGa+FX9bCfCtXRqRjDaaW2qGegDhul+a8qNfcGNypEauRlYw0rbHi0aBbtupWjmWPz7Mj4WjOzJz2GImt0xiolwoRw1oJHSjK8Na7scv5Zr0wb6s15rJW7cZm6ea84lwO2L8yP4ZdD8FUrl8vE5tADDeOgIzB0JE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564730; c=relaxed/simple; bh=7/5TAfily06+zDgTtFfNscdJe8rylw0W1s4rmhLZJx4=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=MsXTxpBF/4VBwLLm5BL9AMfVjyguHj9070KagB4M+bTStj68ycjkcsMcg+7PkHrQq1/FWlibsp3sEsp8Io1AfX+EnYp78C9iwF7HutHUh6zBNMG6+6W0nv1FvF0cf31r4ci2V2XP9Lf2g+6UsuogWa/yf+ZM73edMOdCuVBE1MY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o7XjKTyb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o7XjKTyb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01CBFC43399; Thu, 18 Jan 2024 07:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564729; bh=7/5TAfily06+zDgTtFfNscdJe8rylw0W1s4rmhLZJx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o7XjKTyb7ha08zfAft6E4AXMu7IPPDHT2GEBd7xqRIWlP4MN/r6eXbObCNxLpcDe3 jYm3t4iaLrMGiJnOrnGKzyGd0OJG6YLcHx29qyG1c6CtpxkHmJVSksBMHovAO4Umpi q8rxjEXalAJReXbTj0Nkbg6Cfwf2F1dgSKjKmubihiptBVfCL2OoIeKroK+hpMwiN7 246mqDzM5bqHaH63f+Q7Gfs5tBmZwvbbVyy1bT6CCo/+7yMfID1CmUT+gNqVzqimDj S4YGfnDLLb/Mz3r7Y/KER+320HfaRw06a8nt8CFMkZzlsT0rd9NQfs2qTy/j43LU4G WHv3wkn8ev3fw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 23/45] tty: vt: eliminate unneeded consw::con_putc() implementations Date: Thu, 18 Jan 2024 08:57:34 +0100 Message-ID: <20240118075756.10541-24-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All these consw::con_putc() implementations do the same as consw::con_putcs() (only for one charattr) or even call consw::con_putcs() on their own. Drop them, as thanks to the new con_putc() helper in the previous patch, the console code performs this already -- exactly if consw::con_putc() is missing (NULL). Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/video/console/mdacon.c | 6 ------ drivers/video/console/sticon.c | 12 ------------ drivers/video/console/vgacon.c | 2 -- drivers/video/fbdev/core/fbcon.c | 9 --------- 4 files changed, 29 deletions(-) diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 2ff2c9394d40..01e779943c00 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -427,11 +427,6 @@ static inline u16 *mda_addr(unsigned int x, unsigned int y) return mda_vram_base + y * mda_num_columns + x; } -static void mdacon_putc(struct vc_data *c, int ch, int y, int x) -{ - scr_writew(mda_convert_attr(ch), mda_addr(x, y)); -} - static void mdacon_putcs(struct vc_data *c, const unsigned short *s, int count, int y, int x) { @@ -536,7 +531,6 @@ static const struct consw mda_con = { .con_init = mdacon_init, .con_deinit = mdacon_deinit, .con_clear = mdacon_clear, - .con_putc = mdacon_putc, .con_putcs = mdacon_putcs, .con_cursor = mdacon_cursor, .con_scroll = mdacon_scroll, diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index b1d972d9a31c..2f87b5909d0d 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -71,17 +71,6 @@ static const char *sticon_startup(void) return "STI console"; } -static void sticon_putc(struct vc_data *conp, int c, int ypos, int xpos) -{ - if (vga_is_gfx || console_blanked) - return; - - if (conp->vc_mode != KD_TEXT) - return; - - sti_putc(sticon_sti, c, ypos, xpos, font_data[conp->vc_num]); -} - static void sticon_putcs(struct vc_data *conp, const unsigned short *s, int count, int ypos, int xpos) { @@ -362,7 +351,6 @@ static const struct consw sti_con = { .con_init = sticon_init, .con_deinit = sticon_deinit, .con_clear = sticon_clear, - .con_putc = sticon_putc, .con_putcs = sticon_putcs, .con_cursor = sticon_cursor, .con_scroll = sticon_scroll, diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index c6bd4acbe1d2..2cb75be74c38 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1193,7 +1193,6 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, static void vgacon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, unsigned int width) { } -static void vgacon_putc(struct vc_data *vc, int c, int ypos, int xpos) { } static void vgacon_putcs(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos) { } @@ -1203,7 +1202,6 @@ const struct consw vga_con = { .con_init = vgacon_init, .con_deinit = vgacon_deinit, .con_clear = vgacon_clear, - .con_putc = vgacon_putc, .con_putcs = vgacon_putcs, .con_cursor = vgacon_cursor, .con_scroll = vgacon_scroll, diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 8a31a36483ea..38de0f8723aa 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1292,14 +1292,6 @@ static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, get_color(vc, info, scr_readw(s), 0)); } -static void fbcon_putc(struct vc_data *vc, int c, int ypos, int xpos) -{ - unsigned short chr; - - scr_writew(c, &chr); - fbcon_putcs(vc, &chr, 1, ypos, xpos); -} - static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); @@ -3159,7 +3151,6 @@ static const struct consw fb_con = { .con_init = fbcon_init, .con_deinit = fbcon_deinit, .con_clear = fbcon_clear, - .con_putc = fbcon_putc, .con_putcs = fbcon_putcs, .con_cursor = fbcon_cursor, .con_scroll = fbcon_scroll, From patchwork Thu Jan 18 07:57:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765104 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D98952C878; Thu, 18 Jan 2024 07:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564731; cv=none; b=Xin0WNyctG8Ew2jwcvT54Jorg4JQp6rAMGkus4YARKJswpox9eFwf9Tsjs6TOVsQOwHw0cMtmNtfTIbnUxqI+f9NwA33nN9L+CsqrFIgPDMpVtzxwDtR2c1HTKiv/pejbdy0qB3vIFsfkbYqP+PeObgLkYgTqvitO6rpjmP77Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564731; c=relaxed/simple; bh=nvYd6isOoXNLl9Y7Tt4RQvNbFL1i4ad9TROebYx41cg=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=bpttzLICG8jz52FhMO5KnTXhdXrZbH9ZdQVCzLJ9ilhIfSFIORZnuf2gc01fVtQbkxDrNMdE6bJuf6xepAZX/ndGxmxCYZwK9mAgosx0JGZhXU8wd95rc6F/TaYjhZwM9A+82er6YlXv5q6dC8lOZNyx3URdbsEXkFSBcufwadY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ITZ4P6Mq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ITZ4P6Mq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2103C43394; Thu, 18 Jan 2024 07:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564731; bh=nvYd6isOoXNLl9Y7Tt4RQvNbFL1i4ad9TROebYx41cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ITZ4P6Mq4K83xZkDiJCEeANLdmMnsvIczvgPxZogZOLeFKki4/+vqat+l00bCNSY1 yn1mL3v3jHxAZJkQkEvOBaOb3n9na/vdomfrRHTvzbCTDYz8/Y3Vw2fRnSC5J5Z2h0 DF4dXGGhXr3cfBo/FTOttmKW7ELamSBd50hqTae7NYMSAQ45yMJgJKMahYE1Q5Y1Mz OVJ2zjvaAe5GvtT+yWrS3GmPIqxpeNMbcyDVL7orU9xZ7eE6SYV7GAhCUnto143GRg J914Q1gFIk1c61IJuoMyEOYf7wV159Hr/0LTsZOPkyUk+ftxk0/8kkXwgvkc5cMbGK llyniMC9mXTtg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 24/45] tty: vt: sanitize consw::con_putc() parameters Date: Thu, 18 Jan 2024 08:57:35 +0100 Message-ID: <20240118075756.10541-25-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make parameters of consw::con_putc() saner: * x and y are unsigned now, as they cannot be negative, and * ca is made u16, as it is composed of two 8bit values (character and attribute). See the con_putcs() hook, u16/ushort is worked on there. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/console/dummycon.c | 6 ++++-- drivers/video/console/newport_con.c | 4 ++-- include/linux/console.h | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 0a69d5c216ee..1874beed0325 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -50,7 +50,8 @@ void dummycon_unregister_output_notifier(struct notifier_block *nb) raw_notifier_chain_unregister(&dummycon_output_nh, nb); } -static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) +static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, + unsigned int x) { WARN_CONSOLE_UNLOCKED(); @@ -84,7 +85,8 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) return 1; } #else -static void dummycon_putc(struct vc_data *vc, int c, int ypos, int xpos) { } +static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, + unsigned int x) { } static void dummycon_putcs(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos) { } static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 55c6106b3507..9b5c0118873e 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -367,8 +367,8 @@ static void newport_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, } } -static void newport_putc(struct vc_data *vc, int charattr, int ypos, - int xpos) +static void newport_putc(struct vc_data *vc, u16 charattr, unsigned int ypos, + unsigned int xpos) { unsigned char *p; diff --git a/include/linux/console.h b/include/linux/console.h index 8fd96a5fca5f..92d57e5b3009 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -39,6 +39,8 @@ enum vc_intensity; * @con_init: initialize the console on @vc. @init is true for the very first * call on this @vc. * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. + * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. + * (optional -- @con_putcs would be called instead) * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. @@ -53,7 +55,8 @@ struct consw { void (*con_deinit)(struct vc_data *vc); void (*con_clear)(struct vc_data *vc, unsigned int y, unsigned int x, unsigned int count); - void (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos); + void (*con_putc)(struct vc_data *vc, u16 ca, unsigned int y, + unsigned int x); void (*con_putcs)(struct vc_data *vc, const unsigned short *s, int count, int ypos, int xpos); void (*con_cursor)(struct vc_data *vc, int mode); From patchwork Thu Jan 18 07:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763868 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C4952D022; Thu, 18 Jan 2024 07:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564733; cv=none; b=odiZ0LNc9mjFZlNFrQD3Awvzz3UJtS+9eS0teDNTGqqmjkV3Ks3ASSAhaOatv5GCRlpPM3hBGXB6lwfn9pIXCpNdLCz8Ldw3h6ie7sW2CaIQP2FjKrCI7YzSCZMf3uqKZpcG+/6PNkACHwaCKktz8dLBREh+HCuAqOZmDEVdUcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564733; c=relaxed/simple; bh=AXYnZIWEuWMDEXZj9STOsxhLB7J7xLAWqiFob6JBE7U=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=DdF7sD0xHAYDCaSefROflDAcbG0Li/p3TDWy16q7rJNNe68giymMtRWgNA832WrbP6uKM5qhe70RENI9q1SjWfrsi23pY0QFM8MSwOUF0bK2b8epCdKXVFTxHPzFL8e3rTIlY3fW77NoPySNrX8JouzGxjTC/oo5vepAK1+/HRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WdbtrrVG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WdbtrrVG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37C15C433C7; Thu, 18 Jan 2024 07:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564733; bh=AXYnZIWEuWMDEXZj9STOsxhLB7J7xLAWqiFob6JBE7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WdbtrrVGRVCrWfN80DM2m2Qe4tW9dJI1L9xlDI8irU50XujJcq16YH2zOglW2/9i5 Clv6ufuEs8BMwWgWjY2oJP+Jq+AtOqFaHmSpmC6sUyK8VeFeZt5+tsrpwR7p5EN44b PCGQs5v8bj4X1tXBtkxosD/oGlZGeVizCDR1x8R/Cl/K25tS4+N0o5IlifhCjBIpfQ 0UjUWanWUpVQ3WhrLfQvCAm602EAwRm06EvXQXcgE5n5V2zx1/ug1cv/8edMgw4IVN pWlCU/0I7oUKthoZiGHr3Wy006gDbos3DpIzbVArU7mNKdCOYaTV4QcioBnXUKdpEJ bqOLuGXiPHVdw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 25/45] tty: vt: sanitize consw::con_putcs() parameters Date: Thu, 18 Jan 2024 08:57:36 +0100 Message-ID: <20240118075756.10541-26-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Similar to con_putc() in the previous patch: * make the pointer to charattr a pointer to u16, and * make x, y, and count unsigned as they are strictly non-negative. And again, document that hook. Signed-off-by: Jiri Slaby (SUSE) --- drivers/video/console/dummycon.c | 10 +++++----- drivers/video/console/mdacon.c | 4 ++-- drivers/video/console/newport_con.c | 9 +++++---- drivers/video/console/sticon.c | 4 ++-- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 4 ++-- include/linux/console.h | 6 ++++-- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 1874beed0325..188d9f3e201c 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -59,10 +59,10 @@ static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, raw_notifier_call_chain(&dummycon_output_nh, 0, NULL); } -static void dummycon_putcs(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos) +static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, + unsigned int ypos, unsigned int xpos) { - int i; + unsigned int i; if (!dummycon_putc_called) { /* Ignore erases */ @@ -87,8 +87,8 @@ static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) #else static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, unsigned int x) { } -static void dummycon_putcs(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos) { } +static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, + unsigned int ypos, unsigned int xpos) { } static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) { return 0; diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 01e779943c00..b8822b615b2f 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -427,8 +427,8 @@ static inline u16 *mda_addr(unsigned int x, unsigned int y) return mda_vram_base + y * mda_num_columns + x; } -static void mdacon_putcs(struct vc_data *c, const unsigned short *s, - int count, int y, int x) +static void mdacon_putcs(struct vc_data *c, const u16 *s, unsigned int count, + unsigned int y, unsigned int x) { u16 *dest = mda_addr(x, y); diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 9b5c0118873e..5e65ee0b7c07 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -396,12 +396,13 @@ static void newport_putc(struct vc_data *vc, u16 charattr, unsigned int ypos, RENDER(npregs, p); } -static void newport_putcs(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos) +static void newport_putcs(struct vc_data *vc, const u16 *s, + unsigned int count, unsigned int ypos, + unsigned int xpos) { - int i; - int charattr; unsigned char *p; + unsigned int i; + u16 charattr; charattr = (scr_readw(s) >> 8) & 0xff; diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 2f87b5909d0d..906da1fde7c8 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -71,8 +71,8 @@ static const char *sticon_startup(void) return "STI console"; } -static void sticon_putcs(struct vc_data *conp, const unsigned short *s, - int count, int ypos, int xpos) +static void sticon_putcs(struct vc_data *conp, const u16 *s, unsigned int count, + unsigned int ypos, unsigned int xpos) { if (vga_is_gfx || console_blanked) return; diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 2cb75be74c38..558076462b0d 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1193,8 +1193,8 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b, static void vgacon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, unsigned int width) { } -static void vgacon_putcs(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos) { } +static void vgacon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, + unsigned int ypos, unsigned int xpos) { } const struct consw vga_con = { .owner = THIS_MODULE, diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 38de0f8723aa..7a7b2ac0d7a9 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -1279,8 +1279,8 @@ static void fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, __fbcon_clear(vc, sy, sx, 1, width); } -static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos) +static void fbcon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, + unsigned int ypos, unsigned int xpos) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_display *p = &fb_display[vc->vc_num]; diff --git a/include/linux/console.h b/include/linux/console.h index 92d57e5b3009..82d55764a66f 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -41,6 +41,7 @@ enum vc_intensity; * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. * (optional -- @con_putcs would be called instead) + * @con_putcs: emit @count characters with attributes @s to [@x, @y] on @vc. * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. @@ -57,8 +58,9 @@ struct consw { unsigned int x, unsigned int count); void (*con_putc)(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x); - void (*con_putcs)(struct vc_data *vc, const unsigned short *s, - int count, int ypos, int xpos); + void (*con_putcs)(struct vc_data *vc, const u16 *s, + unsigned int count, unsigned int ypos, + unsigned int xpos); void (*con_cursor)(struct vc_data *vc, int mode); bool (*con_scroll)(struct vc_data *vc, unsigned int top, unsigned int bottom, enum con_scroll dir, From patchwork Thu Jan 18 07:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765103 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 179FC2D054; Thu, 18 Jan 2024 07:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564736; cv=none; b=he8YktdroUWHV5t5ihixijdBV9JNpWCZjYsOPPsFJ0j3b43A+7EQvqzfcPej83uBUTMM8S2+zW5KulZliteZickxU3qnlUAenoejQKs6lulSUyR3GHsN8HJFtH6TcZFzFeVTOCYS6o2yEeEhpUZHSPCf7d25W/lV4gg0IRqJyLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564736; c=relaxed/simple; bh=9KIJ7uIX/Te/xBlz0NrBY1Kbgsi0p9OXSqQTf+AUMRE=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=hgpb3PCF+4y8qNZlOFYvkWm14aVRJpWenih/F3XWN/VU9crd+8uffjQTTcfjyjWLv3hTfuoAhE1Rpgpyh54g/UkUg1hPta82+lR/T5QkjuDKaLGpceEQO7c2wG+GHVr9IgTttew0NVojaoTEg34iSZ59/2g/lIqZvKvZWl29CGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gWdMkNEo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gWdMkNEo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFC7BC43394; Thu, 18 Jan 2024 07:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564735; bh=9KIJ7uIX/Te/xBlz0NrBY1Kbgsi0p9OXSqQTf+AUMRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gWdMkNEosEIzFt3TlKGSERCw7ekEAHgvdERRn98vGLL8K8cC+zOFAAP35i///H94w jYK/cIgBi8mQjWVf9Fl9/G2smPaTnarlwBj10+Gc4XZgWck0NfzdqwZjaI8zH6nI5S qJlEQUbGwb7dkVLGRhor2Jl2jifja7m64uB4vcDsAnf5AXJcEPyRilDecUp7bu5YvX dTZO1ZNPQpszojVWoV3GCVPANPImZRUjcAeCN+zW0yKT6ROo52ZB/dcIU6xYMsPXM/ YGNybHNgZNPxQ7pkgJCsyMsZRL+zTLYLmEzDsyHt2Dm9Xg2VNl7ggo1rsOpeg1F9Yd 2RyBY3pxepqIg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 26/45] consoles: use if instead of switch-case in consw::con_cursor() Date: Thu, 18 Jan 2024 08:57:37 +0100 Message-ID: <20240118075756.10541-27-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is only a preparation for the following cleanup patch to make it easier. Provided CM_ERASE is the only different, use 'if' instead of 'switch+case' in all those. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/console/newport_con.c | 26 +++++------- drivers/video/console/sticon.c | 27 ++++++------ drivers/video/console/vgacon.c | 66 +++++++++++++---------------- 3 files changed, 53 insertions(+), 66 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 5e65ee0b7c07..f852717b88f0 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -443,24 +443,20 @@ static void newport_cursor(struct vc_data *vc, int mode) unsigned short treg; int xcurs, ycurs; - switch (mode) { - case CM_ERASE: - treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); - newport_vc2_set(npregs, VC2_IREG_CONTROL, - (treg & ~(VC2_CTRL_ECDISP))); - break; + treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); - case CM_MOVE: - case CM_DRAW: - treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); + if (mode == CM_ERASE) { newport_vc2_set(npregs, VC2_IREG_CONTROL, - (treg | VC2_CTRL_ECDISP)); - xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2; - ycurs = ((xcurs / vc->vc_cols) << 4) + 31; - xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction; - newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs); - newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); + (treg & ~(VC2_CTRL_ECDISP))); + return; } + + newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg | VC2_CTRL_ECDISP)); + xcurs = (vc->vc_pos - vc->vc_visible_origin) / 2; + ycurs = ((xcurs / vc->vc_cols) << 4) + 31; + xcurs = ((xcurs % vc->vc_cols) << 3) + xcurs_correction; + newport_vc2_set(npregs, VC2_IREG_CURSX, xcurs); + newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); } static int newport_switch(struct vc_data *vc) diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 906da1fde7c8..42480874db00 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -95,23 +95,20 @@ static void sticon_cursor(struct vc_data *conp, int mode) return; car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols]; - switch (mode) { - case CM_ERASE: + if (mode == CM_ERASE) { sti_putc(sticon_sti, car1, conp->state.y, conp->state.x, font_data[conp->vc_num]); - break; - case CM_MOVE: - case CM_DRAW: - switch (CUR_SIZE(conp->vc_cursor_type)) { - case CUR_UNDERLINE: - case CUR_LOWER_THIRD: - case CUR_LOWER_HALF: - case CUR_TWO_THIRDS: - case CUR_BLOCK: - sti_putc(sticon_sti, (car1 & 255) + (0 << 8) + (7 << 11), - conp->state.y, conp->state.x, font_data[conp->vc_num]); - break; - } + return; + } + + switch (CUR_SIZE(conp->vc_cursor_type)) { + case CUR_UNDERLINE: + case CUR_LOWER_THIRD: + case CUR_LOWER_HALF: + case CUR_TWO_THIRDS: + case CUR_BLOCK: + sti_putc(sticon_sti, (car1 & 255) + (0 << 8) + (7 << 11), + conp->state.y, conp->state.x, font_data[conp->vc_num]); break; } } diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 558076462b0d..3bf7f46a8998 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -514,47 +514,41 @@ static void vgacon_cursor(struct vc_data *c, int mode) c_height = c->vc_cell_height; - switch (mode) { - case CM_ERASE: - write_vga(14, (c->vc_pos - vga_vram_base) / 2); + write_vga(14, (c->vc_pos - vga_vram_base) / 2); + + if (mode == CM_ERASE) { if (vga_video_type >= VIDEO_TYPE_VGAC) vgacon_set_cursor_size(31, 30); else vgacon_set_cursor_size(31, 31); - break; + return; + } - case CM_MOVE: - case CM_DRAW: - write_vga(14, (c->vc_pos - vga_vram_base) / 2); - switch (CUR_SIZE(c->vc_cursor_type)) { - case CUR_UNDERLINE: - vgacon_set_cursor_size(c_height - - (c_height < 10 ? 2 : 3), - c_height - - (c_height < 10 ? 1 : 2)); - break; - case CUR_TWO_THIRDS: - vgacon_set_cursor_size(c_height / 3, c_height - - (c_height < 10 ? 1 : 2)); - break; - case CUR_LOWER_THIRD: - vgacon_set_cursor_size(c_height * 2 / 3, c_height - - (c_height < 10 ? 1 : 2)); - break; - case CUR_LOWER_HALF: - vgacon_set_cursor_size(c_height / 2, c_height - - (c_height < 10 ? 1 : 2)); - break; - case CUR_NONE: - if (vga_video_type >= VIDEO_TYPE_VGAC) - vgacon_set_cursor_size(31, 30); - else - vgacon_set_cursor_size(31, 31); - break; - default: - vgacon_set_cursor_size(1, c_height); - break; - } + switch (CUR_SIZE(c->vc_cursor_type)) { + case CUR_UNDERLINE: + vgacon_set_cursor_size(c_height - (c_height < 10 ? 2 : 3), + c_height - (c_height < 10 ? 1 : 2)); + break; + case CUR_TWO_THIRDS: + vgacon_set_cursor_size(c_height / 3, + c_height - (c_height < 10 ? 1 : 2)); + break; + case CUR_LOWER_THIRD: + vgacon_set_cursor_size(c_height * 2 / 3, + c_height - (c_height < 10 ? 1 : 2)); + break; + case CUR_LOWER_HALF: + vgacon_set_cursor_size(c_height / 2, + c_height - (c_height < 10 ? 1 : 2)); + break; + case CUR_NONE: + if (vga_video_type >= VIDEO_TYPE_VGAC) + vgacon_set_cursor_size(31, 30); + else + vgacon_set_cursor_size(31, 31); + break; + default: + vgacon_set_cursor_size(1, c_height); break; } } From patchwork Thu Jan 18 07:57:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763867 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC5612D614; Thu, 18 Jan 2024 07:58:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564738; cv=none; b=MrKToH4r4px3ki9MzQAnvYY0d4bGnNdwl4Qn3wGw2tjxUTKKP337GPfYQIoLNcDh1FmXXl1gnzlUGatBO3a6BWvwwfjMQVecPCDgOiM40sedpaxdnt17ysU/E1tiLglb3KbTJHfpHjddKaRe1+ijz9DM1DaQz9rT7n0h63Wkd4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564738; c=relaxed/simple; bh=6xvbnww7JlLBYTWi11QyGdS/O6ZiCkP8ssfXGVVStMk=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=S259w2J91BbYaL+nPw2RyOlO5XKGARSn1ld2+rWX6Px5FRvPbaqmDp1RmA67u2Ok53lw4I0o6+xXPsmn/yftFuAWquCDcqfoYr79dxrCRzlUleYGODASskz1zGbcAJi4a5ToDMAssgD/DrUuApyrbS3mR9rbvCtOw8kW13+Sz1c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a2R25vDo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a2R25vDo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36171C433B1; Thu, 18 Jan 2024 07:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564738; bh=6xvbnww7JlLBYTWi11QyGdS/O6ZiCkP8ssfXGVVStMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a2R25vDoJz4BOPRUHRYWkdxEDZ2+Es96N38Dy7n38C4ar8g33k/Mi0D5yL7iM5q8w iriWoeFhnXrml8yUHpNoGoGn6rCs9XKHcH3UlWgrOQoMF1NnoU3wOA+1UWuP4ST17j ptUm3pJ6Lk7oHfQMKfRaSx2y4ALD4Vsp4QGyfQ42ZfkIFecZGIV5H851L0gYv93C2C iIdiPt+2zvEoKXNLocvSUY2N164LaEbfdykz1UrZxOyzqZ0f4lKPyyv1n/djv1EAcQ M8QtpBUrLbZKmYX3vJWYUVExgEifFqz2nPP0NcRQbHXG70/hNZSPza0tk1f0F6fG2c Yy3izNATVYncw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Daniel Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 27/45] fbdev/core: simplify cursor_state setting in fbcon_ops::cursor() Date: Thu, 18 Jan 2024 08:57:38 +0100 Message-ID: <20240118075756.10541-28-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is a switch decicing if cursor should be drawn or not. The whole switch can be simplified to one line. Do this cleanup as a preparatory work for the next patch. There, all the CM_* constants are removed. Signed-off-by: Jiri Slaby (SUSE) Cc: Daniel Vetter Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/fbdev/core/bitblit.c | 11 +---------- drivers/video/fbdev/core/fbcon_ccw.c | 11 +---------- drivers/video/fbdev/core/fbcon_cw.c | 11 +---------- drivers/video/fbdev/core/fbcon_ud.c | 11 +---------- 4 files changed, 4 insertions(+), 40 deletions(-) diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c index 8587c9da0670..daff152f4c22 100644 --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c @@ -348,16 +348,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = msk; } - switch (mode) { - case CM_ERASE: - ops->cursor_state.enable = 0; - break; - case CM_DRAW: - case CM_MOVE: - default: - ops->cursor_state.enable = (use_sw) ? 0 : 1; - break; - } + ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c index 2789ace79634..889423d580bc 100644 --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c @@ -349,16 +349,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, kfree(tmp); } - switch (mode) { - case CM_ERASE: - ops->cursor_state.enable = 0; - break; - case CM_DRAW: - case CM_MOVE: - default: - ops->cursor_state.enable = (use_sw) ? 0 : 1; - break; - } + ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c index 86a254c1b2b7..a306ca5802e8 100644 --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c @@ -332,16 +332,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, kfree(tmp); } - switch (mode) { - case CM_ERASE: - ops->cursor_state.enable = 0; - break; - case CM_DRAW: - case CM_MOVE: - default: - ops->cursor_state.enable = (use_sw) ? 0 : 1; - break; - } + ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c index 23bc045769d0..f6fc458b46c7 100644 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -372,16 +372,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = ~msk; } - switch (mode) { - case CM_ERASE: - ops->cursor_state.enable = 0; - break; - case CM_DRAW: - case CM_MOVE: - default: - ops->cursor_state.enable = (use_sw) ? 0 : 1; - break; - } + ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; From patchwork Thu Jan 18 07:57:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765102 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CAAF2D634; Thu, 18 Jan 2024 07:59:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564741; cv=none; b=B0B//5k/98djayWtoBHPpo550iutjxwTbIYimg9SS5z15xyfDhlq8g/1QB9pG39vfaOqGS2Jk62lKacKVtlQpbe23cxDBtighZR7Uz81GAuE3R3nZGEHTRH3Bhi0yzdO5lFfuLPOdd0SQYnmS6z2aQW9N8i2NOwCp4GPwxLsnlk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564741; c=relaxed/simple; bh=hJma+GlHKJaFxInAwETUzzRK9y+Y4oMfcVBpjzoXkYc=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=YwHjKNX8qW23rU73BhvpG2ARcDXCdlM1WWVNdAJmqIyS2Q1f1aIVyCov00oxjek2mmwinGD+mWDW5uTlfjg7qkK/ZlZu881cejy9G+seRs39WIhQgywXtLK9znqmX9g8zi7xurG8hxdsWCFu1tw43iu55jy9nEZwTKL3kn+6qJk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H7/EIMur; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H7/EIMur" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1E77C43390; Thu, 18 Jan 2024 07:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564741; bh=hJma+GlHKJaFxInAwETUzzRK9y+Y4oMfcVBpjzoXkYc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H7/EIMurlFVn42SiwT9vP7eS3CaFgXrcIQU9GLe+WnHKJX5RJXGt1GkwzKpO6mXBj fm0axCprlGcACcTLpy9gXrf0cb3YA9uyFdPZfbCnz2HRh7fBJktOb2a+sccrdfGNVs hZJIwON5/M+wQ0mbnNwO5cwbw+eNcgQ7PFdhEISpSp4cJhw2JLlvpiw5OrGxZQPl61 X/1chWFCep0STki4iU2LrM0T2ovXzmd57o4twCxHqfuw0eW7nP9/SAVSuIgd5hxXXJ rFageAyBofq8g+yDYFCijMvH929jC6b4LBxlAhwup2v9UyzAvogGqHyyDYdHif2ROQ ewvadhTOlGpqw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 28/45] tty: vt: remove CM_* constants Date: Thu, 18 Jan 2024 08:57:39 +0100 Message-ID: <20240118075756.10541-29-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There is no difference between CM_MOVE and CM_DRAW. Either of them enables the cursor. CM_ERASE then disables cursor. So get rid of all of them and use simple "bool enable". Note that this propagates down to the fbcon code. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/tty/vt/vt.c | 4 ++-- drivers/video/console/dummycon.c | 2 +- drivers/video/console/mdacon.c | 4 ++-- drivers/video/console/newport_con.c | 4 ++-- drivers/video/console/sticon.c | 6 +++--- drivers/video/console/vgacon.c | 6 +++--- drivers/video/fbdev/core/bitblit.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 19 +++++++++---------- drivers/video/fbdev/core/fbcon.h | 4 ++-- drivers/video/fbdev/core/fbcon_ccw.c | 4 ++-- drivers/video/fbdev/core/fbcon_cw.c | 4 ++-- drivers/video/fbdev/core/fbcon_ud.c | 4 ++-- drivers/video/fbdev/core/tileblit.c | 4 ++-- include/linux/console.h | 8 ++------ 14 files changed, 36 insertions(+), 41 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 73e48a53dc31..2df306922b4e 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -860,7 +860,7 @@ static void hide_cursor(struct vc_data *vc) if (vc_is_sel(vc)) clear_selection(); - vc->vc_sw->con_cursor(vc, CM_ERASE); + vc->vc_sw->con_cursor(vc, false); hide_softcursor(vc); } @@ -873,7 +873,7 @@ static void set_cursor(struct vc_data *vc) clear_selection(); add_softcursor(vc); if (CUR_SIZE(vc->vc_cursor_type) != CUR_NONE) - vc->vc_sw->con_cursor(vc, CM_DRAW); + vc->vc_sw->con_cursor(vc, true); } else hide_cursor(vc); } diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 188d9f3e201c..1171e27edef7 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -113,7 +113,7 @@ static void dummycon_init(struct vc_data *vc, bool init) static void dummycon_deinit(struct vc_data *vc) { } static void dummycon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, unsigned int width) { } -static void dummycon_cursor(struct vc_data *vc, int mode) { } +static void dummycon_cursor(struct vc_data *vc, bool enable) { } static bool dummycon_scroll(struct vc_data *vc, unsigned int top, unsigned int bottom, enum con_scroll dir, diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index b8822b615b2f..bc851a1d9f4d 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -470,9 +470,9 @@ static int mdacon_blank(struct vc_data *c, int blank, int mode_switch) } } -static void mdacon_cursor(struct vc_data *c, int mode) +static void mdacon_cursor(struct vc_data *c, bool enable) { - if (mode == CM_ERASE) { + if (!enable) { mda_set_cursor(mda_vram_len - 1); return; } diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index f852717b88f0..e35406dea7c7 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -438,14 +438,14 @@ static void newport_putcs(struct vc_data *vc, const u16 *s, } } -static void newport_cursor(struct vc_data *vc, int mode) +static void newport_cursor(struct vc_data *vc, bool enable) { unsigned short treg; int xcurs, ycurs; treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); - if (mode == CM_ERASE) { + if (!enable) { newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg & ~(VC2_CTRL_ECDISP))); return; diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 42480874db00..786e1b3a98ea 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -86,7 +86,7 @@ static void sticon_putcs(struct vc_data *conp, const u16 *s, unsigned int count, } } -static void sticon_cursor(struct vc_data *conp, int mode) +static void sticon_cursor(struct vc_data *conp, bool enable) { unsigned short car1; @@ -95,7 +95,7 @@ static void sticon_cursor(struct vc_data *conp, int mode) return; car1 = conp->vc_screenbuf[conp->state.x + conp->state.y * conp->vc_cols]; - if (mode == CM_ERASE) { + if (!enable) { sti_putc(sticon_sti, car1, conp->state.y, conp->state.x, font_data[conp->vc_num]); return; @@ -121,7 +121,7 @@ static bool sticon_scroll(struct vc_data *conp, unsigned int t, if (vga_is_gfx) return false; - sticon_cursor(conp, CM_ERASE); + sticon_cursor(conp, false); switch (dir) { case SM_UP: diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 3bf7f46a8998..c81723ad4dc1 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -503,7 +503,7 @@ static void vgacon_set_cursor_size(int from, int to) raw_spin_unlock_irqrestore(&vga_lock, flags); } -static void vgacon_cursor(struct vc_data *c, int mode) +static void vgacon_cursor(struct vc_data *c, bool enable) { unsigned int c_height; @@ -516,7 +516,7 @@ static void vgacon_cursor(struct vc_data *c, int mode) write_vga(14, (c->vc_pos - vga_vram_base) / 2); - if (mode == CM_ERASE) { + if (!enable) { if (vga_video_type >= VIDEO_TYPE_VGAC) vgacon_set_cursor_size(31, 30); else @@ -1030,7 +1030,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight) /* void size to cause regs to be rewritten */ cursor_size_lastfrom = 0; cursor_size_lastto = 0; - c->vc_sw->con_cursor(c, CM_DRAW); + c->vc_sw->con_cursor(c, true); } c->vc_font.height = c->vc_cell_height = fontheight; vc_resize(c, 0, rows); /* Adjust console size */ diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c index daff152f4c22..3ff1b2a8659e 100644 --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c @@ -233,7 +233,7 @@ static void bit_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, +static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable, int fg, int bg) { struct fb_cursor cursor; @@ -348,7 +348,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = msk; } - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 7a7b2ac0d7a9..c1765a6ef490 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -351,7 +351,7 @@ static void fb_flashcursor(struct work_struct *work) struct fb_info *info; struct vc_data *vc = NULL; int c; - int mode; + bool enable; int ret; /* FIXME: we should sort out the unbind locking instead */ @@ -375,9 +375,8 @@ static void fb_flashcursor(struct work_struct *work) } c = scr_readw((u16 *) vc->vc_pos); - mode = (!ops->cursor_flash || ops->cursor_state.enable) ? - CM_ERASE : CM_DRAW; - ops->cursor(vc, info, mode, get_color(vc, info, c, 1), + enable = ops->cursor_flash && !ops->cursor_state.enable; + ops->cursor(vc, info, enable, get_color(vc, info, c, 1), get_color(vc, info, c, 0)); console_unlock(); @@ -1301,7 +1300,7 @@ static void fbcon_clear_margins(struct vc_data *vc, int bottom_only) ops->clear_margins(vc, info, margin_color, bottom_only); } -static void fbcon_cursor(struct vc_data *vc, int mode) +static void fbcon_cursor(struct vc_data *vc, bool enable) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; @@ -1317,12 +1316,12 @@ static void fbcon_cursor(struct vc_data *vc, int mode) else fbcon_add_cursor_work(info); - ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1; + ops->cursor_flash = enable; if (!ops->cursor) return; - ops->cursor(vc, info, mode, get_color(vc, info, c, 1), + ops->cursor(vc, info, enable, get_color(vc, info, c, 1), get_color(vc, info, c, 0)); } @@ -1742,7 +1741,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b, if (fbcon_is_inactive(vc, info)) return true; - fbcon_cursor(vc, CM_ERASE); + fbcon_cursor(vc, false); /* * ++Geert: Only use ywrap/ypan if the console is in text mode @@ -2221,7 +2220,7 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) if (!fbcon_is_inactive(vc, info)) { if (ops->blank_state != blank) { ops->blank_state = blank; - fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); + fbcon_cursor(vc, !blank); ops->cursor_flash = (!blank); if (fb_blank(info, blank)) @@ -2649,7 +2648,7 @@ void fbcon_suspended(struct fb_info *info) vc = vc_cons[ops->currcon].d; /* Clear cursor, restore saved data */ - fbcon_cursor(vc, CM_ERASE); + fbcon_cursor(vc, false); } void fbcon_resumed(struct fb_info *info) diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h index 0eaf54a21151..df70ea5ec5b3 100644 --- a/drivers/video/fbdev/core/fbcon.h +++ b/drivers/video/fbdev/core/fbcon.h @@ -61,8 +61,8 @@ struct fbcon_ops { int fg, int bg); void (*clear_margins)(struct vc_data *vc, struct fb_info *info, int color, int bottom_only); - void (*cursor)(struct vc_data *vc, struct fb_info *info, int mode, - int fg, int bg); + void (*cursor)(struct vc_data *vc, struct fb_info *info, + bool enable, int fg, int bg); int (*update_start)(struct fb_info *info); int (*rotate_font)(struct fb_info *info, struct vc_data *vc); struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */ diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c index 889423d580bc..f9b794ff7d39 100644 --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c @@ -218,7 +218,7 @@ static void ccw_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, +static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable, int fg, int bg) { struct fb_cursor cursor; @@ -349,7 +349,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, kfree(tmp); } - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c index a306ca5802e8..903f6fc174e1 100644 --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c @@ -201,7 +201,7 @@ static void cw_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, +static void cw_cursor(struct vc_data *vc, struct fb_info *info, bool enable, int fg, int bg) { struct fb_cursor cursor; @@ -332,7 +332,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, kfree(tmp); } - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c index f6fc458b46c7..594331936fd3 100644 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c @@ -248,7 +248,7 @@ static void ud_clear_margins(struct vc_data *vc, struct fb_info *info, } } -static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, +static void ud_cursor(struct vc_data *vc, struct fb_info *info, bool enable, int fg, int bg) { struct fb_cursor cursor; @@ -372,7 +372,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, mask[i++] = ~msk; } - ops->cursor_state.enable = (mode != CM_ERASE) && !use_sw; + ops->cursor_state.enable = enable && !use_sw; cursor.image.data = src; cursor.image.fg_color = ops->cursor_state.image.fg_color; diff --git a/drivers/video/fbdev/core/tileblit.c b/drivers/video/fbdev/core/tileblit.c index 2768eff247ba..eff7ec4da167 100644 --- a/drivers/video/fbdev/core/tileblit.c +++ b/drivers/video/fbdev/core/tileblit.c @@ -79,7 +79,7 @@ static void tile_clear_margins(struct vc_data *vc, struct fb_info *info, return; } -static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode, +static void tile_cursor(struct vc_data *vc, struct fb_info *info, bool enable, int fg, int bg) { struct fb_tilecursor cursor; @@ -87,7 +87,7 @@ static void tile_cursor(struct vc_data *vc, struct fb_info *info, int mode, cursor.sx = vc->state.x; cursor.sy = vc->state.y; - cursor.mode = (mode == CM_ERASE || use_sw) ? 0 : 1; + cursor.mode = enable && !use_sw; cursor.fg = fg; cursor.bg = bg; diff --git a/include/linux/console.h b/include/linux/console.h index 82d55764a66f..a6a46b5efd66 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -42,6 +42,7 @@ enum vc_intensity; * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. * (optional -- @con_putcs would be called instead) * @con_putcs: emit @count characters with attributes @s to [@x, @y] on @vc. + * @con_cursor: enable/disable cursor depending on @enable * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. @@ -61,7 +62,7 @@ struct consw { void (*con_putcs)(struct vc_data *vc, const u16 *s, unsigned int count, unsigned int ypos, unsigned int xpos); - void (*con_cursor)(struct vc_data *vc, int mode); + void (*con_cursor)(struct vc_data *vc, bool enable); bool (*con_scroll)(struct vc_data *vc, unsigned int top, unsigned int bottom, enum con_scroll dir, unsigned int lines); @@ -128,11 +129,6 @@ static inline void con_debug_enter(struct vc_data *vc) { } static inline void con_debug_leave(void) { } #endif -/* cursor */ -#define CM_DRAW (1) -#define CM_ERASE (2) -#define CM_MOVE (3) - /* * The interface for a console, or any other device that wants to capture * console messages (printer driver?) From patchwork Thu Jan 18 07:57:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763866 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95BC92D794; Thu, 18 Jan 2024 07:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564744; cv=none; b=gRMpzV5+TMrQhfgIx3S8z1FtB5wDlQ5my9+cwEwiEXaleOYofIPjImso4pROyM3xObY2YARet/x7jRm399IlUqEejoDxsIBFaLoNZM74SwRib7mgjPKFGZ+pEst+vPkPIHzGqI93eK/Y+WDIHdk+p1JGmBO3E7H4kMgt1IJtMF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564744; c=relaxed/simple; bh=/NtUvjlmP2hVHln7V3vPbrBUjpMmcUDbRk8I6b5u3TM=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=dd90SLCeTTRJfg7EP6wlEvKwg4gj34eHFO5aVCuv7vOAc2xIjyqkHUrKqvEIKox3XjwiQwppNCMwC2r5AZlZRECtOxq7Bz1Jqy5MQnnHdTVIsRlK8cYdrfoQFIZ1rZ7M/oaSIs3t82gezfNF6gMPebHv/vbjFfTwStm249KTiaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=koG5/fAL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="koG5/fAL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DCD7C433C7; Thu, 18 Jan 2024 07:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564744; bh=/NtUvjlmP2hVHln7V3vPbrBUjpMmcUDbRk8I6b5u3TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=koG5/fALSjBMhxQD9cANZcieQZWPagCgxNq8DEE/hPg7Y1DiHrBgkuMmxThjdhsw9 swC1/fBT593+k3oz/EKujnaldRJLulwXkI8pstExwU0h6e+JYrI3msL5BxHCsPRVqI 0zr2hslPBHXXQhR/ozdEXTyylbmdWwTSYxswYh8FrD3/GvJgkkLwUIwlSXLKytcSes CcNmxKFP8M2ZieeGxshms7JQqsMkfeExzCuwpofVGaSUQJZEK8/GljqBfJFWnWqQZr cqaoBjiPQwjitpOUbx6eC2rjC0c9KE9kxBtzoaT68RNuhlvuv575JwF5GuKBpaKEAk qhGf6lIu8G37g== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 29/45] tty: vt: make consw::con_switch() return a bool Date: Thu, 18 Jan 2024 08:57:40 +0100 Message-ID: <20240118075756.10541-30-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The non-zero (true) return value from consw::con_switch() means a redraw is needed. So make this return type a bool explicitly instead of int. The latter might imply that -Eerrors are expected. They are not. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/tty/vt/vt.c | 2 +- drivers/video/console/dummycon.c | 4 ++-- drivers/video/console/mdacon.c | 4 ++-- drivers/video/console/newport_con.c | 4 ++-- drivers/video/console/sticon.c | 4 ++-- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 6 +++--- include/linux/console.h | 4 +++- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 2df306922b4e..88d7b48871fb 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -970,7 +970,7 @@ void redraw_screen(struct vc_data *vc, int is_switch) } if (redraw) { - int update; + bool update; int old_was_color = vc->vc_can_do_color; set_origin(vc); diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index 1171e27edef7..c8d5aa0e3ed0 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -122,9 +122,9 @@ static bool dummycon_scroll(struct vc_data *vc, unsigned int top, return false; } -static int dummycon_switch(struct vc_data *vc) +static bool dummycon_switch(struct vc_data *vc) { - return 0; + return false; } /* diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index bc851a1d9f4d..4485ef923bb3 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -446,9 +446,9 @@ static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x, scr_memsetw(dest, eattr, width * 2); } -static int mdacon_switch(struct vc_data *c) +static bool mdacon_switch(struct vc_data *c) { - return 1; /* redrawing needed */ + return true; /* redrawing needed */ } static int mdacon_blank(struct vc_data *c, int blank, int mode_switch) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index e35406dea7c7..039d1c9937d2 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -459,7 +459,7 @@ static void newport_cursor(struct vc_data *vc, bool enable) newport_vc2_set(npregs, VC2_IREG_CURSY, ycurs); } -static int newport_switch(struct vc_data *vc) +static bool newport_switch(struct vc_data *vc) { static int logo_drawn = 0; @@ -473,7 +473,7 @@ static int newport_switch(struct vc_data *vc) } } - return 1; + return true; } static int newport_blank(struct vc_data *c, int blank, int mode_switch) diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 786e1b3a98ea..f3bb48a0e980 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -293,9 +293,9 @@ static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx, conp->vc_video_erase_char, font_data[conp->vc_num]); } -static int sticon_switch(struct vc_data *conp) +static bool sticon_switch(struct vc_data *conp) { - return 1; /* needs refreshing */ + return true; /* needs refreshing */ } static int sticon_blank(struct vc_data *c, int blank, int mode_switch) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index c81723ad4dc1..e303098aabab 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -614,7 +614,7 @@ static void vgacon_doresize(struct vc_data *c, raw_spin_unlock_irqrestore(&vga_lock, flags); } -static int vgacon_switch(struct vc_data *c) +static bool vgacon_switch(struct vc_data *c) { int x = c->vc_cols * VGA_FONTWIDTH; int y = c->vc_rows * c->vc_cell_height; @@ -643,7 +643,7 @@ static int vgacon_switch(struct vc_data *c) vgacon_doresize(c, c->vc_cols, c->vc_rows); } - return 0; /* Redrawing not needed */ + return false; /* Redrawing not needed */ } static void vga_set_palette(struct vc_data *vc, const unsigned char *table) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index c1765a6ef490..d5d924225209 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2056,7 +2056,7 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width, return 0; } -static int fbcon_switch(struct vc_data *vc) +static bool fbcon_switch(struct vc_data *vc) { struct fb_info *info, *old_info = NULL; struct fbcon_ops *ops; @@ -2178,9 +2178,9 @@ static int fbcon_switch(struct vc_data *vc) vc->vc_origin + vc->vc_size_row * vc->vc_top, vc->vc_size_row * (vc->vc_bottom - vc->vc_top) / 2); - return 0; + return false; } - return 1; + return true; } static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, diff --git a/include/linux/console.h b/include/linux/console.h index a6a46b5efd66..f7c6b5fc3a36 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -46,6 +46,8 @@ enum vc_intensity; * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. * Return true if no generic handling should be done. * Invoked by csi_M and printing to the console. + * @con_switch: notifier about the console switch; it is supposed to return + * true if a redraw is needed. * @con_set_palette: sets the palette of the console to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional) @@ -66,7 +68,7 @@ struct consw { bool (*con_scroll)(struct vc_data *vc, unsigned int top, unsigned int bottom, enum con_scroll dir, unsigned int lines); - int (*con_switch)(struct vc_data *vc); + bool (*con_switch)(struct vc_data *vc); int (*con_blank)(struct vc_data *vc, int blank, int mode_switch); int (*con_font_set)(struct vc_data *vc, struct console_font *font, unsigned int vpitch, unsigned int flags); From patchwork Thu Jan 18 07:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765101 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C01542D79B; Thu, 18 Jan 2024 07:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564746; cv=none; b=j2qzOZ2H7WvCURm16GXfVV/VnyJPbgAa/HHEs0txIypj73EGxDYZaAyRSrj+R0gsP6PTP+l12+9Eo6VnopUokPSBkWdOa/LFfMigK1IVCMz4mQyXGFgMHzpb3Gp4hEBIv+qFTUvDHtzKhJymfNk2svCly2EBmDqSsl/QqrieNVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564746; c=relaxed/simple; bh=1JA5AooyZLXGqVCAGbSDSuK+q4Ohn8Zc6gZRRlzf9bA=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=h2r2iCoaYS4GJtgUvwq8oZzI6aW5jKrzt+EfkOrPe+7qBRTumnsPp0w91cnuh+OI2yntCasbCgzTxjVbmBXGXn1oGs9z9F0+HU1iuqrR8XLrQbBsudl+dxrg5YnU7XjgsQqoxX0hk3a54fgi6SJYOfiFHnCfVmO18NAAXFCaxd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BXfXfYoS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BXfXfYoS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89967C43601; Thu, 18 Jan 2024 07:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564746; bh=1JA5AooyZLXGqVCAGbSDSuK+q4Ohn8Zc6gZRRlzf9bA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BXfXfYoSYpvTCIeWRHpilD2rVpaS8JT+XmLttQvYBF0iQLK2W4NJbrdXyAjLkiTyI 94OswkcWBFi2tCRhwgda1dfssgJ4B6prz1UWT44wB+bRKQSLpQNansdc+sxKatxcnD 2/h6mnDRiA3gkqcElSRnBLvCGceeH1VuShDp2gcwENBfBZjG0ekzdVWXR+jfcei/BM kH9KJr3y9m3zN1HmFO5wqML5y/KtdOdHjsBejxY1JLSe6VXlTeA+5HRBH+zX8eBVY1 9qugeiDF/Uxezsim4HQom06kGaN85b4gJ4SPM2uKC2WabkFW/VZQXozWOlsmTR9upz Z24rUj6n1kQww== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 30/45] tty: vt: stop using -1 for blank mode in consw::con_blank() Date: Thu, 18 Jan 2024 08:57:41 +0100 Message-ID: <20240118075756.10541-31-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 -1 is the same as VESA_VSYNC_SUSPEND in all con_blank() implementations. So we can remove this special case from vgacon now too. Despite con_blank() of fbcon looks complicated, the "if (!fbcon_is_inactive(vc, info))" branch is not taken as we set "ops->graphics = 1;" few lines above. So what matters there (as in all other blank implementations except vgacon) is if 'blank' is zero or not. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/tty/vt/vt.c | 2 +- drivers/video/console/vgacon.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 88d7b48871fb..279f802aa222 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4361,7 +4361,7 @@ void do_blank_screen(int entering_gfx) if (entering_gfx) { hide_cursor(vc); save_screen(vc); - vc->vc_sw->con_blank(vc, -1, 1); + vc->vc_sw->con_blank(vc, 1, 1); console_blanked = fg_console + 1; blank_state = blank_off; set_origin(vc); diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index e303098aabab..5025ab501f02 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -814,7 +814,6 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch) /* Tell console.c that it has to restore the screen itself */ return 1; case 1: /* Normal blanking */ - case -1: /* Obsolete */ if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) { vga_pal_blank(&vgastate); vga_palette_blanked = true; From patchwork Thu Jan 18 07:57:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763865 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8612F2E3F3; Thu, 18 Jan 2024 07:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564749; cv=none; b=bdGToDT5iCHhsFkwr4jWRRIyUK29pNl2cfu3Y7NbwH1x7l55A3AQ4NJrnLtK8E19pq5qnHWaPHWA+5thHoYTGDunUB4kYU2G0sOR8QoEMTLHoatok7O65WsoRY+HUCM8Wn0ZAQg4YOSz4rAeaAXICHr5jQRxyO74GcxAEUm/G7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564749; c=relaxed/simple; bh=3+fT7y4vRss9smAO0NdBzkZKlN2+aEu/ZpMHzkjUSRM=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=CSrJRLQ4h6RRwk1hzSn0fonlZqvQeEfGUcvSG386MoCmcNFPyasdzyclK6o5fIL9HAFbNFB4b+rbOXYdyOCgPhkdHesj7m09cLk9z+JIBI4he7CqCa0N2a9MWS2dZDvQtuW39epqxFpf5/9YQoKiHIL7Hq/fogUdgb8Rlrisfuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dZuUz3QQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dZuUz3QQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4524C433F1; Thu, 18 Jan 2024 07:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564749; bh=3+fT7y4vRss9smAO0NdBzkZKlN2+aEu/ZpMHzkjUSRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZuUz3QQy7z4YnVtOpAZWlvuuNO8+VJFV+d1OrC2KG9SmTWRPzZoyww1Nrzm25dgG 1hCs3IG555y/b+v8eYzlMKQZ3FcV4uCmUQJVrgvRL/63w0XFzWFWNKl1+iErUopqTd woIZSZQIiCdKayF1AAjlAdlpiDwYoE6tSkMas8FuT25MWYSz+ZthdlNulvknLFvLQg XkBSJEOYIdNDakmud3yLFkEvf6/25pb5j6xJEIyfarcM4yztrAKtebP0IbdDcxgPqc FssbfWajDfp3CoJmWZygp6MS59lhXp8d9ClglygKzLeCKQ3QByYezTzWfj1/RAsyGq 8WdXKeHwn8Izg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 31/45] tty: vt: use VESA blanking constants Date: Thu, 18 Jan 2024 08:57:42 +0100 Message-ID: <20240118075756.10541-32-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are VESA blanking constants defined in console.h already. So use them in the console code instead of constant values. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/tty/vt/vt.c | 9 +++++---- drivers/video/console/newport_con.c | 2 +- drivers/video/console/sticon.c | 2 +- drivers/video/console/vgacon.c | 6 +++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 279f802aa222..6f46fefedcfb 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4334,7 +4334,7 @@ static int set_vesa_blanking(u8 __user *mode_user) return -EFAULT; console_lock(); - vesa_blank_mode = (mode < 4) ? mode : 0; + vesa_blank_mode = (mode < 4) ? mode : VESA_NO_BLANKING; console_unlock(); return 0; @@ -4361,7 +4361,7 @@ void do_blank_screen(int entering_gfx) if (entering_gfx) { hide_cursor(vc); save_screen(vc); - vc->vc_sw->con_blank(vc, 1, 1); + vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1); console_blanked = fg_console + 1; blank_state = blank_off; set_origin(vc); @@ -4382,7 +4382,8 @@ void do_blank_screen(int entering_gfx) save_screen(vc); /* In case we need to reset origin, blanking hook returns 1 */ - i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); + i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND : + (vesa_blank_mode + 1), 0); console_blanked = fg_console + 1; if (i) set_origin(vc); @@ -4433,7 +4434,7 @@ void do_unblank_screen(int leaving_gfx) } console_blanked = 0; - if (vc->vc_sw->con_blank(vc, 0, leaving_gfx)) + if (vc->vc_sw->con_blank(vc, VESA_NO_BLANKING, leaving_gfx)) /* Low-level driver cannot restore -> do it ourselves */ update_screen(vc); if (console_blank_hook) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 039d1c9937d2..ad3a09142770 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -480,7 +480,7 @@ static int newport_blank(struct vc_data *c, int blank, int mode_switch) { unsigned short treg; - if (blank == 0) { + if (blank == VESA_NO_BLANKING) { /* unblank console */ treg = newport_vc2_get(npregs, VC2_IREG_CONTROL); newport_vc2_set(npregs, VC2_IREG_CONTROL, diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index f3bb48a0e980..817b89c45e81 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -300,7 +300,7 @@ static bool sticon_switch(struct vc_data *conp) static int sticon_blank(struct vc_data *c, int blank, int mode_switch) { - if (blank == 0) { + if (blank == VESA_NO_BLANKING) { if (mode_switch) vga_is_gfx = 0; return 1; diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 5025ab501f02..910dc73874b7 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -800,10 +800,10 @@ static void vga_pal_blank(struct vgastate *state) static int vgacon_blank(struct vc_data *c, int blank, int mode_switch) { switch (blank) { - case 0: /* Unblank */ + case VESA_NO_BLANKING: /* Unblank */ if (vga_vesa_blanked) { vga_vesa_unblank(&vgastate); - vga_vesa_blanked = 0; + vga_vesa_blanked = VESA_NO_BLANKING; } if (vga_palette_blanked) { vga_set_palette(c, color_table); @@ -813,7 +813,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch) vga_is_gfx = false; /* Tell console.c that it has to restore the screen itself */ return 1; - case 1: /* Normal blanking */ + case VESA_VSYNC_SUSPEND: /* Normal blanking */ if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) { vga_pal_blank(&vgastate); vga_palette_blanked = true; From patchwork Thu Jan 18 07:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765100 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 829A82E415; Thu, 18 Jan 2024 07:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564752; cv=none; b=k/5Jp24QDGfIHXetmFCo38VZmIwOnkn9z36sDhs+CD47rm3rnF5x8IQBnTQOndqFTgvq24gWA568djNYNCJbWttLQaUTs+llJM7hoCHHzpIlUp9WfyCWA+AbZh4fNP/8avrNoMEJBSZGXZzxGMEvyZTtr+bSWQdMDi0GCZijyjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564752; c=relaxed/simple; bh=sWdw69RTGW8wkTF4nCHD10DhuNSKeBaHpeIrGzhwVTI=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=k/5k3Cu44EI5dXMft9A3qOf/oMnBhpmu0Xx2fSYFFmkqg7MB4Nz9BQSLVIaBCtjMRv3fpd4nApoMoQy8kKzReqFdnsFx/45oHYVqXB3vnbYcKx/x7DVkrFT5bVxOq57f8GXw9i16xw5mBMdp6eqewwLfpq0RN8MlF7H+IXdOVxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rp0y5fyR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rp0y5fyR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96711C433A6; Thu, 18 Jan 2024 07:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564752; bh=sWdw69RTGW8wkTF4nCHD10DhuNSKeBaHpeIrGzhwVTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rp0y5fyRiI8JmKdCwxJjSlQjCa3xtxG3CYpRTOA5D/Mb+2uiHdXAuCYnfEZObisjV PUNke+wnIe9f3cIVL7BwH+54cD+74J0R4pj/U3xkTYDESMrqemSW+QpXLG7PZXm0vp hQ+sFjcBEmhoa1l3oeHpWFBBTJiw41DKVuyQ2Y52DRDW5HSDGHHCRPTbH7FP221qRV mVq7nEQYULSsnxJ3/oMeCkSZZCLcd7XrIdLPwjGJNHZ8ej+JqdUumzxIfEJs3zEmUS cEm3a0q7gkp5f4hqjWRjH4piGsJjdk0bdSXnI5fF8TMsU57kEr9mXS4zfjk5joZ+wt R1vm3gOgDJgMA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 32/45] tty: vt: use enum for VESA blanking modes Date: Thu, 18 Jan 2024 08:57:43 +0100 Message-ID: <20240118075756.10541-33-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch VESA macros to an enum and add and use VESA_BLANK_MAX. This improves type checking in consw::con_blank(). There is a downside of this. The macros were defined twice: in linux/console.h and uapi/linux/fb.h. We cannot remove the latter (uapi header), but nor we want to expand them in the kernel too. So protect them using __KERNEL__. In the kernel case, include linux/console.h instead. This header dependency is preexisting. Alternatively, we could create a vesa.h header with that sole enum and include it. If it turns out linux/console.h is too much for fb.h. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/tty/vt/vt.c | 4 ++-- drivers/video/console/dummycon.c | 6 ++++-- drivers/video/console/mdacon.c | 3 ++- drivers/video/console/newport_con.c | 3 ++- drivers/video/console/sticon.c | 3 ++- drivers/video/console/vgacon.c | 7 ++++--- drivers/video/fbdev/core/fbcon.c | 3 ++- include/linux/console.h | 18 +++++++++++------- include/uapi/linux/fb.h | 5 ++++- 9 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 6f46fefedcfb..756291f37d47 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -175,7 +175,7 @@ int do_poke_blanked_console; int console_blanked; EXPORT_SYMBOL(console_blanked); -static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */ +static enum vesa_blank_mode vesa_blank_mode; static int vesa_off_interval; static int blankinterval; core_param(consoleblank, blankinterval, int, 0444); @@ -4334,7 +4334,7 @@ static int set_vesa_blanking(u8 __user *mode_user) return -EFAULT; console_lock(); - vesa_blank_mode = (mode < 4) ? mode : VESA_NO_BLANKING; + vesa_blank_mode = (mode <= VESA_BLANK_MAX) ? mode : VESA_NO_BLANKING; console_unlock(); return 0; diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index c8d5aa0e3ed0..d86c1d798690 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -79,7 +79,8 @@ static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, raw_notifier_call_chain(&dummycon_output_nh, 0, NULL); } -static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) +static int dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank, + int mode_switch) { /* Redraw, so that we get putc(s) for output done while blanked */ return 1; @@ -89,7 +90,8 @@ static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, unsigned int x) { } static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, unsigned int ypos, unsigned int xpos) { } -static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) +static int dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank, + int mode_switch) { return 0; } diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 4485ef923bb3..63e3ce678aab 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -451,7 +451,8 @@ static bool mdacon_switch(struct vc_data *c) return true; /* redrawing needed */ } -static int mdacon_blank(struct vc_data *c, int blank, int mode_switch) +static int mdacon_blank(struct vc_data *c, enum vesa_blank_mode blank, + int mode_switch) { if (mda_type == TYPE_MDA) { if (blank) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index ad3a09142770..38437a53b7f1 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -476,7 +476,8 @@ static bool newport_switch(struct vc_data *vc) return true; } -static int newport_blank(struct vc_data *c, int blank, int mode_switch) +static int newport_blank(struct vc_data *c, enum vesa_blank_mode blank, + int mode_switch) { unsigned short treg; diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 817b89c45e81..e9d5d1f92883 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -298,7 +298,8 @@ static bool sticon_switch(struct vc_data *conp) return true; /* needs refreshing */ } -static int sticon_blank(struct vc_data *c, int blank, int mode_switch) +static int sticon_blank(struct vc_data *c, enum vesa_blank_mode blank, + int mode_switch) { if (blank == VESA_NO_BLANKING) { if (mode_switch) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 910dc73874b7..a4bd97ab502d 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -81,7 +81,7 @@ static unsigned int vga_video_num_lines; /* Number of text lines */ static bool vga_can_do_color; /* Do we support colors? */ static unsigned int vga_default_font_height __read_mostly; /* Height of default screen font */ static unsigned char vga_video_type __read_mostly; /* Card type */ -static int vga_vesa_blanked; +static enum vesa_blank_mode vga_vesa_blanked; static bool vga_palette_blanked; static bool vga_is_gfx; static bool vga_512_chars; @@ -683,7 +683,7 @@ static struct { unsigned char ClockingMode; /* Seq-Controller:01h */ } vga_state; -static void vga_vesa_blank(struct vgastate *state, int mode) +static void vga_vesa_blank(struct vgastate *state, enum vesa_blank_mode mode) { /* save original values of VGA controller registers */ if (!vga_vesa_blanked) { @@ -797,7 +797,8 @@ static void vga_pal_blank(struct vgastate *state) } } -static int vgacon_blank(struct vc_data *c, int blank, int mode_switch) +static int vgacon_blank(struct vc_data *c, enum vesa_blank_mode blank, + int mode_switch) { switch (blank) { case VESA_NO_BLANKING: /* Unblank */ diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index d5d924225209..69be5f2106bc 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2198,7 +2198,8 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, } } -static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) +static int fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank, + int mode_switch) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; diff --git a/include/linux/console.h b/include/linux/console.h index f7c6b5fc3a36..5ea984b8c5e4 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -31,6 +31,15 @@ enum con_scroll { SM_DOWN, }; +/* Note: fbcon defines the below as macros for userspace (in fb.h). */ +enum vesa_blank_mode { + VESA_NO_BLANKING = 0, + VESA_VSYNC_SUSPEND = 1, + VESA_HSYNC_SUSPEND = 2, + VESA_POWERDOWN = VESA_VSYNC_SUSPEND | VESA_HSYNC_SUSPEND, + VESA_BLANK_MAX = VESA_POWERDOWN, +}; + enum vc_intensity; /** @@ -69,7 +78,8 @@ struct consw { unsigned int bottom, enum con_scroll dir, unsigned int lines); bool (*con_switch)(struct vc_data *vc); - int (*con_blank)(struct vc_data *vc, int blank, int mode_switch); + int (*con_blank)(struct vc_data *vc, enum vesa_blank_mode blank, + int mode_switch); int (*con_font_set)(struct vc_data *vc, struct console_font *font, unsigned int vpitch, unsigned int flags); int (*con_font_get)(struct vc_data *vc, struct console_font *font, @@ -520,12 +530,6 @@ void vcs_remove_sysfs(int index); */ extern atomic_t ignore_console_lock_warning; -/* VESA Blanking Levels */ -#define VESA_NO_BLANKING 0 -#define VESA_VSYNC_SUSPEND 1 -#define VESA_HSYNC_SUSPEND 2 -#define VESA_POWERDOWN 3 - extern void console_init(void); /* For deferred console takeover */ diff --git a/include/uapi/linux/fb.h b/include/uapi/linux/fb.h index 3a49913d006c..562bdbb76ad9 100644 --- a/include/uapi/linux/fb.h +++ b/include/uapi/linux/fb.h @@ -294,11 +294,14 @@ struct fb_con2fbmap { }; /* VESA Blanking Levels */ +#ifdef __KERNEL__ +#include +#else #define VESA_NO_BLANKING 0 #define VESA_VSYNC_SUSPEND 1 #define VESA_HSYNC_SUSPEND 2 #define VESA_POWERDOWN 3 - +#endif enum { /* screen: unblanked, hsync: on, vsync: on */ From patchwork Thu Jan 18 07:57:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763864 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EF5B2E632; Thu, 18 Jan 2024 07:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564755; cv=none; b=ieqtRonyebjPl+6yDHavpt8XIiONsZLGM3wf09CTGLDoO43pZS4FQe/8l3tEMMqQJAkhw7G5EWt2xfhKoPHxw8jobeuRhIBUYArVvwxiU4P0PmR/0dpSjCdC5E1cHIqguV0sNlkRX8dspEj0ddX5jrN8WTSsAUxs0Yq0PnI6plY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564755; c=relaxed/simple; bh=H6hFlY1FKBPnsfs08mbVDqLPJxxBmDB7umf0hERzFOM=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=iNz6q/aECeipHEO4EGUOoxnMbxxW8BtHs5cvtgfO/nnURCVIXBx1puVNSCVZRBrL/pMI0aHrFcGSMxv+TxIAxEz/52UkyXDE0Vzwq5LNEs2hpXdKHDPLgzysfUySa0mWc9vh29Hx2NQtljjTzKXpInenNeqMD3+fxNiea0AJcNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PbURXVIx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PbURXVIx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8260EC433C7; Thu, 18 Jan 2024 07:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564754; bh=H6hFlY1FKBPnsfs08mbVDqLPJxxBmDB7umf0hERzFOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbURXVIxrpXhbi7nr/4F5QemRMJEqFVM6N1wnr1uHu69ybzThUUTF03tAqXd4boXc JNlMC1DkV5FGrjRhDp3i2cslbC3OnW90bpr1vfZ2TZZsMXfO0uGg0vE4oocaCqg2Jn 47yHHjsRi3xjhVJKNYErMYNMB3OgQVJwoNrZIHPCqaUaaxUR73hyO/sA2wqEIxg8PO QQoZf4TMvMGyrEXfWW7fleB5kOYe46iiss3W2oNZk3V3T5xraRZvFL+GAEu+ZhYpfk r8HkpYc/+kMAQNXiD8Siqrq8CKu1nLjWUYpN7wG7yWq/aFKnLS+blbmINMoMnJN0z7 QHy8Ge5WZuNcQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 33/45] tty: vt: make types around consw::con_blank() bool Date: Thu, 18 Jan 2024 08:57:44 +0100 Message-ID: <20240118075756.10541-34-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Both the mode_switch parameter and the return value (a redraw needed) are true/false. So switch them to bool, so that users won't return -Eerrors or anything else. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/video/console/dummycon.c | 12 ++++++------ drivers/video/console/mdacon.c | 8 ++++---- drivers/video/console/newport_con.c | 7 ++++--- drivers/video/console/sticon.c | 9 +++++---- drivers/video/console/vgacon.c | 4 ++-- drivers/video/fbdev/core/fbcon.c | 6 +++--- include/linux/console.h | 7 +++++-- 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/video/console/dummycon.c b/drivers/video/console/dummycon.c index d86c1d798690..139049368fdc 100644 --- a/drivers/video/console/dummycon.c +++ b/drivers/video/console/dummycon.c @@ -79,21 +79,21 @@ static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, raw_notifier_call_chain(&dummycon_output_nh, 0, NULL); } -static int dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank, - int mode_switch) +static bool dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank, + bool mode_switch) { /* Redraw, so that we get putc(s) for output done while blanked */ - return 1; + return true; } #else static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, unsigned int x) { } static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, unsigned int ypos, unsigned int xpos) { } -static int dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank, - int mode_switch) +static bool dummycon_blank(struct vc_data *vc, enum vesa_blank_mode blank, + bool mode_switch) { - return 0; + return false; } #endif diff --git a/drivers/video/console/mdacon.c b/drivers/video/console/mdacon.c index 63e3ce678aab..c0e1f4554a44 100644 --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -451,8 +451,8 @@ static bool mdacon_switch(struct vc_data *c) return true; /* redrawing needed */ } -static int mdacon_blank(struct vc_data *c, enum vesa_blank_mode blank, - int mode_switch) +static bool mdacon_blank(struct vc_data *c, enum vesa_blank_mode blank, + bool mode_switch) { if (mda_type == TYPE_MDA) { if (blank) @@ -460,14 +460,14 @@ static int mdacon_blank(struct vc_data *c, enum vesa_blank_mode blank, mda_convert_attr(c->vc_video_erase_char), c->vc_screenbuf_size); /* Tell console.c that it has to restore the screen itself */ - return 1; + return true; } else { if (blank) outb_p(0x00, mda_mode_port); /* disable video */ else outb_p(MDA_MODE_VIDEO_EN | MDA_MODE_BLINK_EN, mda_mode_port); - return 0; + return false; } } diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 38437a53b7f1..dbb31bf87bf1 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -476,8 +476,8 @@ static bool newport_switch(struct vc_data *vc) return true; } -static int newport_blank(struct vc_data *c, enum vesa_blank_mode blank, - int mode_switch) +static bool newport_blank(struct vc_data *c, enum vesa_blank_mode blank, + bool mode_switch) { unsigned short treg; @@ -492,7 +492,8 @@ static int newport_blank(struct vc_data *c, enum vesa_blank_mode blank, newport_vc2_set(npregs, VC2_IREG_CONTROL, (treg & ~(VC2_CTRL_EDISP))); } - return 1; + + return true; } static int newport_set_font(int unit, struct console_font *op, unsigned int vpitch) diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index e9d5d1f92883..cbb9ef438214 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -298,19 +298,20 @@ static bool sticon_switch(struct vc_data *conp) return true; /* needs refreshing */ } -static int sticon_blank(struct vc_data *c, enum vesa_blank_mode blank, - int mode_switch) +static bool sticon_blank(struct vc_data *c, enum vesa_blank_mode blank, + bool mode_switch) { if (blank == VESA_NO_BLANKING) { if (mode_switch) vga_is_gfx = 0; - return 1; + return true; } sti_clear(sticon_sti, 0, 0, c->vc_rows, c->vc_cols, BLANK, font_data[c->vc_num]); if (mode_switch) vga_is_gfx = 1; - return 1; + + return true; } static u8 sticon_build_attr(struct vc_data *conp, u8 color, diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index a4bd97ab502d..1ef318bac703 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -797,8 +797,8 @@ static void vga_pal_blank(struct vgastate *state) } } -static int vgacon_blank(struct vc_data *c, enum vesa_blank_mode blank, - int mode_switch) +static bool vgacon_blank(struct vc_data *c, enum vesa_blank_mode blank, + bool mode_switch) { switch (blank) { case VESA_NO_BLANKING: /* Unblank */ diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 69be5f2106bc..eee2adf5c682 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2198,8 +2198,8 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info, } } -static int fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank, - int mode_switch) +static bool fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank, + bool mode_switch) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); struct fbcon_ops *ops = info->fbcon_par; @@ -2238,7 +2238,7 @@ static int fbcon_blank(struct vc_data *vc, enum vesa_blank_mode blank, else fbcon_add_cursor_work(info); - return 0; + return false; } static void fbcon_debug_enter(struct vc_data *vc) diff --git a/include/linux/console.h b/include/linux/console.h index 5ea984b8c5e4..fbb32e702472 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -57,6 +57,9 @@ enum vc_intensity; * Invoked by csi_M and printing to the console. * @con_switch: notifier about the console switch; it is supposed to return * true if a redraw is needed. + * @con_blank: blank/unblank the console. The target mode is passed in @blank. + * @mode_switch is set if changing from/to text/graphics. The hook + * is supposed to return true if a redraw is needed. * @con_set_palette: sets the palette of the console to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional) @@ -78,8 +81,8 @@ struct consw { unsigned int bottom, enum con_scroll dir, unsigned int lines); bool (*con_switch)(struct vc_data *vc); - int (*con_blank)(struct vc_data *vc, enum vesa_blank_mode blank, - int mode_switch); + bool (*con_blank)(struct vc_data *vc, enum vesa_blank_mode blank, + bool mode_switch); int (*con_font_set)(struct vc_data *vc, struct console_font *font, unsigned int vpitch, unsigned int flags); int (*con_font_get)(struct vc_data *vc, struct console_font *font, From patchwork Thu Jan 18 07:57:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765099 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B4822E658; Thu, 18 Jan 2024 07:59:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564758; cv=none; b=ga9YxpYF77lmtxQPTcTrg9uniIFD9sOVI2Hw53EAoHpUgGwa7Ft0BNSBf4VDBVSr6IWQQIbR8ljQOjGtTtCianr/mBiJ69fnTMbI7pCiE+QMYHt5+bpi3kYRMGObz9PA8YiIz3ljh29M4J0+E1p5fzEaz7VfOOmE13pZiBmNSeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564758; c=relaxed/simple; bh=cqURl25QFkwlFyKcGIxTktkkLSYtk64KcuI48GLYf8A=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=XpswdcYBwVqkkg6Ktiv4Ui7KPbHUMWiZLJtCphLStJeIR6Hab5lnLbyP+jkDFK5Xn+KF5qY/gYsav81fvGMdbcEcsi8ohZvN9hXAfFrSvjpKG3RyE+hDFN/FCmFslOxZEb7Q6kYaya1PGt/tSqm3mqfRz0bhbqLlOA+sBnPcljk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C+Nw7bll; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C+Nw7bll" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F517C433F1; Thu, 18 Jan 2024 07:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564757; bh=cqURl25QFkwlFyKcGIxTktkkLSYtk64KcuI48GLYf8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C+Nw7bllyMMp9LW+nGs6s5cMq8GxD1xEhsl+LyPb+D7NjAqEPnAooDk2st5GaPUng EZY93HjviMzPAH1v6SYzao5utDo0FP1nuLHH0pt024gPrC3cjuFMJy92iJS97DU8n/ tNHy9V3+yS0xUm7+bsgPS+cgI9t28Kxg3k+sgFZkzAqTjy9a3fDViBz+Md1UcwBG+3 xY0JbJGWt6+yd5A/kd8I/TrGRbUz+Zj/m7nayBsjTBo24hCZOc7zTW0s6fw95br8t1 hFYwYfJH6eMtgkQ6Dx/IQF6judXryBJLzqhVHhXA3jrTOcHomG0/W8Augcq2Me9q+3 WC5kUnF7wEymA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 34/45] tty: vt: make font of consw::con_font_set() const Date: Thu, 18 Jan 2024 08:57:45 +0100 Message-ID: <20240118075756.10541-35-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Provided the font parameter of consw::con_font_set() is not supposed to be changed, make it const. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/tty/vt/vt.c | 2 +- drivers/video/console/newport_con.c | 5 +++-- drivers/video/console/sticon.c | 4 ++-- drivers/video/console/vgacon.c | 2 +- drivers/video/fbdev/core/fbcon.c | 2 +- include/linux/console.h | 5 +++-- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 756291f37d47..196c849ca492 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4639,7 +4639,7 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op) return rc; } -static int con_font_set(struct vc_data *vc, struct console_font_op *op) +static int con_font_set(struct vc_data *vc, const struct console_font_op *op) { struct console_font font; int rc = -EINVAL; diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index dbb31bf87bf1..4203bd5fd0a1 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -496,7 +496,8 @@ static bool newport_blank(struct vc_data *c, enum vesa_blank_mode blank, return true; } -static int newport_set_font(int unit, struct console_font *op, unsigned int vpitch) +static int newport_set_font(int unit, const struct console_font *op, + unsigned int vpitch) { int w = op->width; int h = op->height; @@ -568,7 +569,7 @@ static int newport_font_default(struct vc_data *vc, struct console_font *op, cha return newport_set_def_font(vc->vc_num, op); } -static int newport_font_set(struct vc_data *vc, struct console_font *font, +static int newport_font_set(struct vc_data *vc, const struct console_font *font, unsigned int vpitch, unsigned int flags) { return newport_set_font(vc->vc_num, font, vpitch); diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index cbb9ef438214..710201fb8ce4 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -153,7 +153,7 @@ static void sticon_set_def_font(int unit) } } -static int sticon_set_font(struct vc_data *vc, struct console_font *op, +static int sticon_set_font(struct vc_data *vc, const struct console_font *op, unsigned int vpitch) { struct sti_struct *sti = sticon_sti; @@ -253,7 +253,7 @@ static int sticon_font_default(struct vc_data *vc, struct console_font *op, char return 0; } -static int sticon_font_set(struct vc_data *vc, struct console_font *font, +static int sticon_font_set(struct vc_data *vc, const struct console_font *font, unsigned int vpitch, unsigned int flags) { return sticon_set_font(vc, font, vpitch); diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 1ef318bac703..ea086b39c6f5 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1039,7 +1039,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight) return 0; } -static int vgacon_font_set(struct vc_data *c, struct console_font *font, +static int vgacon_font_set(struct vc_data *c, const struct console_font *font, unsigned int vpitch, unsigned int flags) { unsigned charcount = font->charcount; diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index eee2adf5c682..62474630c4d4 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2460,7 +2460,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, * but lets not assume that, since charcount of 512 is small for unicode support. */ -static int fbcon_set_font(struct vc_data *vc, struct console_font *font, +static int fbcon_set_font(struct vc_data *vc, const struct console_font *font, unsigned int vpitch, unsigned int flags) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); diff --git a/include/linux/console.h b/include/linux/console.h index fbb32e702472..a500caadbad0 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -83,8 +83,9 @@ struct consw { bool (*con_switch)(struct vc_data *vc); bool (*con_blank)(struct vc_data *vc, enum vesa_blank_mode blank, bool mode_switch); - int (*con_font_set)(struct vc_data *vc, struct console_font *font, - unsigned int vpitch, unsigned int flags); + int (*con_font_set)(struct vc_data *vc, + const struct console_font *font, + unsigned int vpitch, unsigned int flags); int (*con_font_get)(struct vc_data *vc, struct console_font *font, unsigned int vpitch); int (*con_font_default)(struct vc_data *vc, From patchwork Thu Jan 18 07:57:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763863 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0D7A2E83E; Thu, 18 Jan 2024 07:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564761; cv=none; b=Z3T5rHlQv3qLSiBvo7URsTUJTi+SLvCZumHV1YSM/LBcmiRjsCiNkBoc0RF/tqYE+2qfgFftqd8Lrb+Q3tJWAeSAGQZ3FioED1RaA6yPpPlHYELxjZKmGL4/GvMSQZUHDtlom1FurTLuRj56H5xP8eLGzV1V0Fu3bKle5CYIqq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564761; c=relaxed/simple; bh=Im8qOCVaj+4w2v1mizWr2yWT3oRa0+WvQVJnYj7lSCk=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=MkwuoaIbMNC6NjWxr3Od6+23Pz84yvmcHiTMEe9LTJZnG3b1HufAjeraPLyfwmKbo4RQJdCOw53tzF/dl0qOCpcLL8cCc5s/65jv7HuxL/9CaRddDidWGYJvApqFrbtlWRg5vylsPNVUefUV9gnt9ept6bhHUbz/0EAMO0dZBc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aO86wFPu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aO86wFPu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BC2EC43390; Thu, 18 Jan 2024 07:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564760; bh=Im8qOCVaj+4w2v1mizWr2yWT3oRa0+WvQVJnYj7lSCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aO86wFPuU7xm+mwlp1yIceaoXtHHKEu5EHeM6NBsV8s1KhFQbtH/hVlTMhHU/e4rm M29VfvbYs/tvDnTBQn1+T5RJu2fnX5UlSR0IzX0UnWItZNluI0nl1mi3QqVd6iQGrX iGSFFwaY5gjSxP9q/+MsBvmSEKiIvrmxezqUk9dmkS4vylIWL90dS55IyO+1oF4sjQ L6aa++wDmsiB+fKeQAWxFFBV75OsdPP7ktL0oZubljkFgLoHwWw7GtGgIr405z524m uEGAHbeR3I4fgjDtXCPyjamZnuzTaj6mqeAO/73YBXgNnU6IqSJLifcx/elfKsoEZT 1C/fqcdr/T+sQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , "James E.J. Bottomley" , Daniel Vetter , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-parisc@vger.kernel.org Subject: [PATCH 35/45] tty: vt: make consw::con_font_default()'s name const Date: Thu, 18 Jan 2024 08:57:46 +0100 Message-ID: <20240118075756.10541-36-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's a name after all and that is not supposed to be changed. So make it const to make this obvious. Signed-off-by: Jiri Slaby (SUSE) Cc: "James E.J. Bottomley" Cc: Daniel Vetter Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org --- drivers/video/console/newport_con.c | 3 ++- drivers/video/console/sticon.c | 3 ++- drivers/video/fbdev/core/fbcon.c | 3 ++- include/linux/console.h | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index 4203bd5fd0a1..a51cfc1d560e 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -564,7 +564,8 @@ static int newport_set_def_font(int unit, struct console_font *op) return 0; } -static int newport_font_default(struct vc_data *vc, struct console_font *op, char *name) +static int newport_font_default(struct vc_data *vc, struct console_font *op, + const char *name) { return newport_set_def_font(vc->vc_num, op); } diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c index 710201fb8ce4..4c7b4959a1aa 100644 --- a/drivers/video/console/sticon.c +++ b/drivers/video/console/sticon.c @@ -246,7 +246,8 @@ static int sticon_set_font(struct vc_data *vc, const struct console_font *op, return 0; } -static int sticon_font_default(struct vc_data *vc, struct console_font *op, char *name) +static int sticon_font_default(struct vc_data *vc, struct console_font *op, + const char *name) { sticon_set_def_font(vc->vc_num); diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 62474630c4d4..657160eec0a5 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2533,7 +2533,8 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font, 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) +static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, + const char *name) { struct fb_info *info = fbcon_info_from_console(vc->vc_num); const struct font_desc *f; diff --git a/include/linux/console.h b/include/linux/console.h index a500caadbad0..543de22a3f23 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -89,7 +89,7 @@ struct consw { int (*con_font_get)(struct vc_data *vc, struct console_font *font, unsigned int vpitch); int (*con_font_default)(struct vc_data *vc, - struct console_font *font, char *name); + struct console_font *font, const char *name); int (*con_resize)(struct vc_data *vc, unsigned int width, unsigned int height, bool from_user); void (*con_set_palette)(struct vc_data *vc, From patchwork Thu Jan 18 07:57:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765098 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FB0B2E852; Thu, 18 Jan 2024 07:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564763; cv=none; b=H3uLUjCAH7tF3AcYNqu76DX7u2xJpFKdV2Gpl2Vzso/kq6wWYdJSpPlGoWgy1dwQZX+mV0Pr2uzIMYpU4TPKnf31as+StVYWG47FdNoicbhlY7wdnvPMAmFQF+NJkJ9XvaJe4OqNxw6hejg0CQX7n0e3dIAYkKsgoj1v/svSq2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564763; c=relaxed/simple; bh=+Fey0ueL3fs+YfoywPjRe7ybSQ7PCBnb+Q6J1ddQlD8=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=kRoTueQQ1jXNNEv3So2SHnBJ0z4pqjIkfW9KUpHe+cMD8gPWn6WxrK24v6Dqs5paDS8/XZm9XNBEq9bm6SoddDbiqEDF9g9tqy8NckFCYgSaVG7d52EwlzRl56aURtgRUlkwRWSRUmSxp68mDSWMjAa7jlJk6h7rG11Yikz2bPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i6d0N+d0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i6d0N+d0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 158B8C43399; Thu, 18 Jan 2024 07:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564762; bh=+Fey0ueL3fs+YfoywPjRe7ybSQ7PCBnb+Q6J1ddQlD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i6d0N+d0AoOKuyftlq2UstduK0SAteraz7/1E0aTPJEQfef6OmG9CSofeaGqyUdKA hwKgSj9tEJR5fT59H/Izk8fUdoEqrDAEWg/N87P+xddlAIv6psQeNzXX7udJPzfYd2 M01zz2/WKFXSoo20pLY4mZuIErSwMTflEv1KDIFx2kCwSQ9msgpt5yxukoKWhs8Ty5 Ltu0WoFKcFd6E0TFeYwWmSoPigVQXjaktPHZLdn7CCYJ+61ZPt/a1BdxYNNQrKLYAK UX41bBxpOaqaLe+xJFhNfhsK4GsZHLYKXFOgcbA2Kcp/O/o19WoqssSadd5S49uwx4 rp8Eqbl0abYRA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 36/45] tty: vt: change consw::con_set_origin() return type Date: Thu, 18 Jan 2024 08:57:47 +0100 Message-ID: <20240118075756.10541-37-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The return value of consw::con_set_origin() is only true/false, meaining if vc->vc_origin is set to vc->vc_screenbuf or not. So switch the type and returned values accordingly. And document the hook. Signed-off-by: Jiri Slaby (SUSE) Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/console/vgacon.c | 8 ++++---- include/linux/console.h | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index ea086b39c6f5..4a40da81990d 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -65,7 +65,7 @@ static struct vgastate vgastate; * Interface used by the world */ -static int vgacon_set_origin(struct vc_data *c); +static bool vgacon_set_origin(struct vc_data *c); static struct uni_pagedict *vgacon_uni_pagedir; static int vgacon_refcount; @@ -1100,15 +1100,15 @@ static int vgacon_resize(struct vc_data *c, unsigned int width, return 0; } -static int vgacon_set_origin(struct vc_data *c) +static bool vgacon_set_origin(struct vc_data *c) { if (vga_is_gfx || /* We don't play origin tricks in graphic modes */ (console_blanked && !vga_palette_blanked)) /* Nor we write to blanked screens */ - return 0; + return false; c->vc_origin = c->vc_visible_origin = vga_vram_base; vga_set_mem_top(c); vga_rolled_over = 0; - return 1; + return true; } static void vgacon_save_screen(struct vc_data *c) diff --git a/include/linux/console.h b/include/linux/console.h index 543de22a3f23..c07e1ce6bd14 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -63,6 +63,9 @@ enum vc_intensity; * @con_set_palette: sets the palette of the console to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional) + * @con_set_origin: set origin (see &vc_data::vc_origin) of the @vc. If not + * provided or returns false, the origin is set to + * @vc->vc_screenbuf. (optional) */ struct consw { struct module *owner; @@ -95,7 +98,7 @@ struct consw { void (*con_set_palette)(struct vc_data *vc, const unsigned char *table); void (*con_scrolldelta)(struct vc_data *vc, int lines); - int (*con_set_origin)(struct vc_data *vc); + bool (*con_set_origin)(struct vc_data *vc); void (*con_save_screen)(struct vc_data *vc); u8 (*con_build_attr)(struct vc_data *vc, u8 color, enum vc_intensity intensity, From patchwork Thu Jan 18 07:57:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763862 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86E7D3175F; Thu, 18 Jan 2024 07:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564765; cv=none; b=DmmErLgYz/UnMf4a3V+rs0Zfqm56xpoHGXEflI94U7h+5p9a5m9sdzNhfA1630aFQPFV9NdIVZ9oPWSzTSzwP04M1IGZQ4CmUxR5zEx2VsqLGmalfHPv8wjt6CbCdr4JymbpuKU44V8xvFT4kO3kVV1oeLbgQXffdrPoWUqbUj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564765; c=relaxed/simple; bh=GuttBthplzcWAD92DYxHAXefieOSH/0KZn+o6peTBWY=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=mEkngoU3cYmiWnwij/X9XI7LM0lKlNlYezAh+L5/MHcHzCj34cxIl/fWMmzPulAS1pCk1t6d5AHH9GUToc3sMtHvdeEpwjznYReDJFLuQPX5e4WYCzvBELxsaXepIoBGkLzbGl6WjigS52nIcV4AurUbwDjRlpBfvtvX3zQpgiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jK+FEF6c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jK+FEF6c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 604ADC433C7; Thu, 18 Jan 2024 07:59:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564765; bh=GuttBthplzcWAD92DYxHAXefieOSH/0KZn+o6peTBWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jK+FEF6cWzI+fO9Fnk6BTANz83FQ+Lf1d+PsJX7UgvaZ3SD0ojQzqBSQUAT0/ca6V Y74TcR+ajAzxBP+CHyJf5GIpa9w6z6aLiowoJ4h0OiNZ5YLqLYiTaf20qygE60FF2e zQ7thTa4t7woijOADtWIoBemY1RBlSKro8h/aNmGhYzubDfgWf3VoNwdxIdB6+TbU1 CFQHvk5E6jfSXOeGV3Thu6bwPJbURfO657v2/3kfXKyKWqS9m4bA5F9iQYRBM68YR8 tWk0jTTDeyqpvaaMIptgZrva5raYWF4rBZOCHDGJsZoW6VNoRuSpOrRKm5HZ+6rS9C 9X1GNlPY2Opww== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Daniel Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 37/45] fbcon: remove consw::con_screen_pos() Date: Thu, 18 Jan 2024 08:57:48 +0100 Message-ID: <20240118075756.10541-38-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 fbcon_screen_pos() performs the same as the default implementation. The only difference in the default implementation is that is considers both vc->vc_origin and vc->vc_visible_origin. But given fbcon's softscroll code was already removed in commit 50145474f6ef (fbcon: remove soft scrollback code), both are always the same. So remove fbcon_screen_pos() too. Signed-off-by: Jiri Slaby (SUSE) Cc: Daniel Vetter Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/fbdev/core/fbcon.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 657160eec0a5..2166ea1a5430 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2593,11 +2593,6 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table) fb_set_cmap(&palette_cmap, info); } -static u16 *fbcon_screen_pos(const struct vc_data *vc, int offset) -{ - return (u16 *) (vc->vc_origin + offset); -} - static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos, int *px, int *py) { @@ -3162,7 +3157,6 @@ static const struct consw fb_con = { .con_font_default = fbcon_set_def_font, .con_set_palette = fbcon_set_palette, .con_invert_region = fbcon_invert_region, - .con_screen_pos = fbcon_screen_pos, .con_getxy = fbcon_getxy, .con_resize = fbcon_resize, .con_debug_enter = fbcon_debug_enter, From patchwork Thu Jan 18 07:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765097 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9436931A9A; Thu, 18 Jan 2024 07:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564767; cv=none; b=sxC058dPq+nRNAcoJFecN9cz3Oht1Qmrl/CIisYjk1I6X68qnTJkRFSFgf5WuPvv5qk2d0lSb8Ya9fzk1PkVETLeaIi9x/rt6e//vBYWJ3cTgejQp1kjZVJO1AE8mI5FitPF0dqbTp06fI2Knh4PDZJ/cNdo7jLyfcm+emTg+pA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564767; c=relaxed/simple; bh=ySZcU9jF42JuV+7z6emCEUbJtD0/5xrFJi0CmG4Ho7Y=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=Kb32kyjbrRZIUh7lB3U4MQAxRUBNpZA1OZFMFHU0tjmTG85VpjWYiViAsVAxd1P640H+7hgaZ4Oygph6GJj0vXdlRsqq2vqkSg9M+CtRCzoM/pdmXcjA5fTgohxxMXsntMBN4MosWpw5FcNzWoIEv34e0btvec+TIt0asw47+tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EO+yOELZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EO+yOELZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB092C43390; Thu, 18 Jan 2024 07:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564767; bh=ySZcU9jF42JuV+7z6emCEUbJtD0/5xrFJi0CmG4Ho7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EO+yOELZvBiaXuPeIQ9rss9TXpxzH4LELNUO3Np+v3e7EUGgOKCuB2lrBJcUpsW8x hNclnoABAbqcFqGlXTsavzxPWVnmVaFbUlB35ov7q6E0NNbJhbLFRTE1A2iR0e2jD6 qG9yS77hcXvr8TAZlZWn4m6J4KmKEpWsKS2gWrOEGVHWZtuJ91z95BvuZInQ44935A Uu7KiTl4Hx81EsUip2XTR7j9zeEzlIS2ihqshlB6PN8fsmKsC9QLC3DsupNbVX5X4E J8RCadSx1IzB1Trhax9PZSE2MrufdHM31/YaBCV55QvTTHTrzycTu8DHNF9VkK2xLb Gm5kpri/1r8xw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 38/45] tty: vt: remove consw::con_screen_pos() Date: Thu, 18 Jan 2024 08:57:49 +0100 Message-ID: <20240118075756.10541-39-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 After the previous patch, nobody sets that hook. So drop it completely. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 12 +++--------- include/linux/console.h | 1 - 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 196c849ca492..b41ecf3a5fc7 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -289,15 +289,9 @@ static inline bool con_should_update(const struct vc_data *vc) static inline unsigned short *screenpos(const struct vc_data *vc, int offset, bool viewed) { - unsigned short *p; - - if (!viewed) - p = (unsigned short *)(vc->vc_origin + offset); - else if (!vc->vc_sw->con_screen_pos) - p = (unsigned short *)(vc->vc_visible_origin + offset); - else - p = vc->vc_sw->con_screen_pos(vc, offset); - return p; + unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; + + return (unsigned short *)(origin + offset); } static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x) diff --git a/include/linux/console.h b/include/linux/console.h index c07e1ce6bd14..2c8a77865437 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -104,7 +104,6 @@ struct consw { enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic); void (*con_invert_region)(struct vc_data *vc, u16 *p, int count); - u16 *(*con_screen_pos)(const struct vc_data *vc, int offset); unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position, int *px, int *py); /* From patchwork Thu Jan 18 07:57:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763861 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E55BE321B5; Thu, 18 Jan 2024 07:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564769; cv=none; b=ZYqA7syIhf2HHvSTAGMMx/fkqPjmLpo63QZ8dwXFd+UZT0GEM5p0Knxmcs73eYn9+CdvC53oTUljHHk/WKpzSLjXaGbASdsWrdKOdXHbikWM9fk1/Nh9y/MkmQVmieMjoIyGGWLXr3UdL2S3eR8h98xQNKcKWjFwlhvaA22eEBY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564769; c=relaxed/simple; bh=23taMT4+1oTMyrJp90CFddN2xRCEJnbtzQNugverJ2M=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=fQQttoa5hRz/LEpkeX5bRr4565+YnCMgb2kZf4xjtQUWsk0BxXRejJXg8jrNicSsYOVtmtybT82bAGXBwdNqt4Qlenh7m9t8iFDhIQAXZtFL/rtS763RR4Q2cTxYIvttSz2bYZ7mR+BuKws6izSfE4AMqJ0kxAiny5Q8ZLA66Kc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ra20Y7g1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ra20Y7g1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E277C43399; Thu, 18 Jan 2024 07:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564768; bh=23taMT4+1oTMyrJp90CFddN2xRCEJnbtzQNugverJ2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ra20Y7g1Ek/3qxHoB4wK4zo3QN6kt/TguuwGOdD4HwCUyqqTYYRpZQLBvDM5oxdf6 vvpxLzFbl9hFdFq+0LtiOCtgFX5nyhQdSxTz7fc1Qawk4WKS+tTt4Vdv1xr8xJzF3c ZZ9w8zsdrLR1ArEajGYzkA91zf2YNAz7A9H2uSfW6zNDzQuXmuBzCefxOb7GRwjILi e3kYzfrymTH92VQAToNCT5piNyqTNTexGXC90gvUN15iQ9i5fcKuOr/1PjBz5QxMuM 3C9aEIqjb93pA4xj5kID/Z7jdS7d+o15zVyP3KUsPxBbJbRgsitfCMfZ423pPTEO1n KW+RnYXUCxlmQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 39/45] tty: vt: make types of screenpos() more consistent Date: Thu, 18 Jan 2024 08:57:50 +0100 Message-ID: <20240118075756.10541-40-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 * parameter offset: it is expected to be non-negative, so switch to unsigned * return type: switch from ushort to explicit u16. This is expected on most places. And fix the remaining two places too. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index b41ecf3a5fc7..69d85a030ebc 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -286,12 +286,12 @@ static inline bool con_should_update(const struct vc_data *vc) return con_is_visible(vc) && !console_blanked; } -static inline unsigned short *screenpos(const struct vc_data *vc, int offset, - bool viewed) +static inline u16 *screenpos(const struct vc_data *vc, unsigned int offset, + bool viewed) { unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; - return (unsigned short *)(origin + offset); + return (u16 *)(origin + offset); } static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned int x) @@ -705,7 +705,7 @@ static void update_attr(struct vc_data *vc) /* Note: inverting the screen twice should revert to the original state */ void invert_screen(struct vc_data *vc, int offset, int count, bool viewed) { - unsigned short *p; + u16 *p; WARN_CONSOLE_UNLOCKED(); @@ -773,8 +773,7 @@ void complement_pos(struct vc_data *vc, int offset) if (offset != -1 && offset >= 0 && offset < vc->vc_screenbuf_size) { unsigned short new; - unsigned short *p; - p = screenpos(vc, offset, true); + u16 *p = screenpos(vc, offset, true); old = scr_readw(p); new = old ^ vc->vc_complement_mask; scr_writew(new, p); From patchwork Thu Jan 18 07:57:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765096 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DF9E328D8; Thu, 18 Jan 2024 07:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564771; cv=none; b=d4ahxnDCPU57tDa3OVX/6xtwws6PIw23rtg896A3BimupFDe/X4S0dfu5jRmlNS070lm7pORb5Vbt5rOcDBPpn3yWuDM5GEIYbYbKL5Ff9vC/Yah3Vhk4d2j3MVK+2RZK/eyFg7tnXFw5fZU4OKARj2bapbS8WkNTleLFupmJMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564771; c=relaxed/simple; bh=TxyfiQSfnfbUMhKRrQ0H1rTP3kUo5bAgp6fUTnxFTJs=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=bHw8UnXbq4V4HrBgb58ax3KT7GaOG1sXsYONA+ALzS3UyXSYyZoytch3fmyHucgCs/VwpIkab+XnnDjfaikOT9+9FfnKO5umf5cATf5t4SY5VIO/JQKPSXweaQwNEctcvs9woqeollObZdzg0r6PrHZZVnk3feKnNYtdp6jmGDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ls3qFhFQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ls3qFhFQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43FF8C433F1; Thu, 18 Jan 2024 07:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564771; bh=TxyfiQSfnfbUMhKRrQ0H1rTP3kUo5bAgp6fUTnxFTJs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ls3qFhFQJLk9RLW/rjJ1Jett3RJ2P/AFQ7Df/lDXsXPvS1FzS26Z7HI/QewF2b+/U Mz4Eb1WyZd91E07cU+rSVgy4EPOU6Zhb2nsAQh+p6lVxyOYtTjSlFHulF7f3DxuIJ2 harnNn3m0oAUYTpiCu4KOWWtCq7DTPSGupGYPrNlybSuNWeqYSXIYkK0EfCMSfmBxr aOSsYKFA9BOJGvKUFBZS0d5yOFJb+2FFk3jSrILvO7bXc64tpqgkrwASSNl/HImMdt tlvamhci8HICutVrmQw9zyHDGzXueJkb5qtFoTstxUeNb7BhOJOAuZe1o+A5pU/HU0 9XwFxrpzYlKPg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Daniel Vetter , Helge Deller , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH 40/45] fbcon: remove fbcon_getxy() Date: Thu, 18 Jan 2024 08:57:51 +0100 Message-ID: <20240118075756.10541-41-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Again, fbcon_getxy() is the same as the default implementation since the softscroll removal in commit 50145474f6ef (fbcon: remove soft scrollback code). Drop that. Signed-off-by: Jiri Slaby (SUSE) Cc: Daniel Vetter Cc: Helge Deller Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org --- drivers/video/fbdev/core/fbcon.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 2166ea1a5430..9c2962900d13 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2593,30 +2593,6 @@ static void fbcon_set_palette(struct vc_data *vc, const unsigned char *table) fb_set_cmap(&palette_cmap, info); } -static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos, - int *px, int *py) -{ - unsigned long ret; - int x, y; - - if (pos >= vc->vc_origin && pos < vc->vc_scr_end) { - unsigned long offset = (pos - vc->vc_origin) / 2; - - x = offset % vc->vc_cols; - y = offset / vc->vc_cols; - ret = pos + (vc->vc_cols - x) * 2; - } else { - /* Should not happen */ - x = y = 0; - ret = vc->vc_origin; - } - if (px) - *px = x; - if (py) - *py = y; - return ret; -} - /* As we might be inside of softback, we may work with non-contiguous buffer, that's why we have to use a separate routine. */ static void fbcon_invert_region(struct vc_data *vc, u16 * p, int cnt) @@ -3157,7 +3133,6 @@ static const struct consw fb_con = { .con_font_default = fbcon_set_def_font, .con_set_palette = fbcon_set_palette, .con_invert_region = fbcon_invert_region, - .con_getxy = fbcon_getxy, .con_resize = fbcon_resize, .con_debug_enter = fbcon_debug_enter, .con_debug_leave = fbcon_debug_leave, From patchwork Thu Jan 18 07:57:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763860 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 779C933CE9; Thu, 18 Jan 2024 07:59:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564773; cv=none; b=FlFfZUWCzsexKdbD4Yrd05pIMDdHD/2XhI+hlRD0u0CIsCd8GFpFBiH7wjv3Q6kgJtz6EU/C73Z3khrueiw9TTncem17mTQnSvUSmd0WjlOcRvh6lP6VrKLKn1iTCaY1pgGrDQjKM/yDtUrO5uWDtvdF5wX3d2xmw/x3kKJnwO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564773; c=relaxed/simple; bh=MR+NuATfSYHNVmx82TTROPf/5gbNbFwpQP6yg+dZ/d8=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=n8YrPSKtcp898pyBFGo7LePCfKsjrDQQuEWhoGCBwuIOTZn5LFjoOlPIJ6oc4sTYADvHW9mC9nyuxG3F8vwx39G3PYHuCdLJsysCo4d+aUY7uVl61O0KUQnytUB48KfBW2MEFicaLiDbhGxkSJ3wN5Y+F2h9JQhEBaCqrsVBK48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mm3nIJXo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mm3nIJXo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1C54C43394; Thu, 18 Jan 2024 07:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564773; bh=MR+NuATfSYHNVmx82TTROPf/5gbNbFwpQP6yg+dZ/d8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mm3nIJXoZMPbRn4yehphjA5VP8jv7ep9JhBxEfhuYCDk0idvxkfB8kRTLlcMeXOcY 8D5oo3k0XgbY4mpLCB0P45Xe/qoDHlBish90lFuBmG6ptmwuvCustOCMVaqn3wfaro LfkFKcB1WU4mT/24kObB4tnvtX06ZY2DyfafcEeGQe+ZElizURKKnOPyfxsgHoY3Ge faE2ZUcOyUgz7ATMwVKPGRqsJ4IUfCA41v8MknixBgxtDZjopejqneroTpoy9jYfDV DPU5EfjBkfasr4kvKuPw4e5wB5plYE+iN1l4M5bbmMWjo/b1mv0olTJ9ZqY4TtsHrk +Rt/xvfnq6OTA== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 41/45] tty: vt: remove consw::con_getxy() Date: Thu, 18 Jan 2024 08:57:52 +0100 Message-ID: <20240118075756.10541-42-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 After the previous patch, nobody sets that hook. So drop it completely. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 20 +++++--------------- include/linux/console.h | 2 -- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 69d85a030ebc..539b30e198a9 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -593,18 +593,12 @@ static void con_scroll(struct vc_data *vc, unsigned int top, static void do_update_region(struct vc_data *vc, unsigned long start, int count) { unsigned int xx, yy, offset; - u16 *p; + u16 *p = (u16 *)start; + + offset = (start - vc->vc_origin) / 2; + xx = offset % vc->vc_cols; + yy = offset / vc->vc_cols; - p = (u16 *) start; - if (!vc->vc_sw->con_getxy) { - offset = (start - vc->vc_origin) / 2; - xx = offset % vc->vc_cols; - yy = offset / vc->vc_cols; - } else { - int nxx, nyy; - start = vc->vc_sw->con_getxy(vc, start, &nxx, &nyy); - xx = nxx; yy = nyy; - } for(;;) { u16 attrib = scr_readw(p) & 0xff00; int startx = xx; @@ -627,10 +621,6 @@ static void do_update_region(struct vc_data *vc, unsigned long start, int count) break; xx = 0; yy++; - if (vc->vc_sw->con_getxy) { - p = (u16 *)start; - start = vc->vc_sw->con_getxy(vc, start, NULL, NULL); - } } } diff --git a/include/linux/console.h b/include/linux/console.h index 2c8a77865437..c0525ccc54d9 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -104,8 +104,6 @@ struct consw { enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic); void (*con_invert_region)(struct vc_data *vc, u16 *p, int count); - unsigned long (*con_getxy)(struct vc_data *vc, unsigned long position, - int *px, int *py); /* * Flush the video console driver's scrollback buffer */ From patchwork Thu Jan 18 07:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765095 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D04B8339A8; Thu, 18 Jan 2024 07:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564774; cv=none; b=mVNo9IdWeNNkI2Gm9Aickaboi1xGZGia4N8bibMELhRZZAT7XVCpDz10TED4Xw9hJ1wvdvNueAPnEPDZ5Het7NCnaCNI0ZloAR69bHVrA8U2Pj2uUKvXT/cSeaftJhciwiFNHULTVtokECdX56melTxTZWOumahAAw/T4tM7PmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564774; c=relaxed/simple; bh=RC22BQx0kbG70JjJvH62n7U8+Gh474y8m3MFwF6L5Vs=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=HE6KRKuKa9AkHHvHvUgYQuU94x1XOK5KgPg1lX3IzJePP6LiEdofIeX8srlfJ/vVI7SvCKV53OBG/12o80F+KPX8js8Ed0GKAsDGxFGGqNI1d1B+tUc3855bLs7ceujOts+Ty9vO08pkFw95lQWIzIABc4Stc/5uyYVHxnXR2Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sLwZ4F05; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sLwZ4F05" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76835C433A6; Thu, 18 Jan 2024 07:59:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564774; bh=RC22BQx0kbG70JjJvH62n7U8+Gh474y8m3MFwF6L5Vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sLwZ4F05MrYEF54KC/+C3qaXPotuwtG5E4/LIWqd42k0DIVfjhyMWHuy5iR4b3pnP B0vgYo+YNOnimfSCP+beBBIqfzDWsrz1XbOnQAPV1YgT+66P4FIobRWhTgvdT3xJMt lYSEjuJSR7B6/wnwWpUwlfbqDdnwCs6TnuDydwIggaBZE6NPZN+nziOyENdGrUa+L7 zfKfct2SexL9ymi++7ojdRfEgiJmhmDLcrTsQZWUH6N5QQJ7U1FkPzi+at9D0EASM2 heblFF/nqaaMjlc7c4wHRzDdO+ufo6c1+MT4rVPMV9Zh69MVluZ8yNsFGc///B/WHC 93PwawjfuRlWg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 42/45] tty: vt: remove unused consw::con_flush_scrollback() Date: Thu, 18 Jan 2024 08:57:53 +0100 Message-ID: <20240118075756.10541-43-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 consw::con_flush_scrollback() is unused since commit 973c096f6a85 (vgacon: remove software scrollback support). Drop it. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 27 ++++++++++++--------------- include/linux/console.h | 4 ---- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 539b30e198a9..35d303017653 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -888,21 +888,18 @@ static void flush_scrollback(struct vc_data *vc) WARN_CONSOLE_UNLOCKED(); set_origin(vc); - if (vc->vc_sw->con_flush_scrollback) { - vc->vc_sw->con_flush_scrollback(vc); - } else if (con_is_visible(vc)) { - /* - * When no con_flush_scrollback method is provided then the - * legacy way for flushing the scrollback buffer is to use - * a side effect of the con_switch method. We do it only on - * the foreground console as background consoles have no - * scrollback buffers in that case and we obviously don't - * want to switch to them. - */ - hide_cursor(vc); - vc->vc_sw->con_switch(vc); - set_cursor(vc); - } + if (!con_is_visible(vc)) + return; + + /* + * The legacy way for flushing the scrollback buffer is to use a side + * effect of the con_switch method. We do it only on the foreground + * console as background consoles have no scrollback buffers in that + * case and we obviously don't want to switch to them. + */ + hide_cursor(vc); + vc->vc_sw->con_switch(vc); + set_cursor(vc); } /* diff --git a/include/linux/console.h b/include/linux/console.h index c0525ccc54d9..698a2f7576b0 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -104,10 +104,6 @@ struct consw { enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic); void (*con_invert_region)(struct vc_data *vc, u16 *p, int count); - /* - * Flush the video console driver's scrollback buffer - */ - void (*con_flush_scrollback)(struct vc_data *vc); /* * Prepare the console for the debugger. This includes, but is not * limited to, unblanking the console, loading an appropriate From patchwork Thu Jan 18 07:57:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763859 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAA9034CF0; Thu, 18 Jan 2024 07:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564776; cv=none; b=Ag144STAzQfZ683rethtELFdx3Rvm/ZEyBtUbjcbZ1UtsPGPGJcPd4Dy3Yd+fnFAZnjaN9vXkPVM3YvxnQSqhzcqCxTzhnVRcyVkIFV+QQHvV/UMGMTm97TnJsmrKvynTxbNwPAqCKhCf11m3zjXcjxOUJXROR1gMNJeLwMP4nI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564776; c=relaxed/simple; bh=RPsg4+ITmM9gFoQ7ZYe+JsyD9TMljUbzbnXkyjAN+G4=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=F9VL/bPndsbukQ8nWmKQVi+2HIfyVz8aC+F+AQLaO6sC3FPKKsWPJwz3A2DcIXoIBi9L9CukSbhVmuIqvE9B0pxEmqrO84TLYft87Dc6vVMwOWg3MPUoDWaOem/B/ABx3H0VlC+HdifkYdkPelDmlzT0Uj5BKU0tQR1l/rXLOMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i7rsVnzZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i7rsVnzZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C647C433C7; Thu, 18 Jan 2024 07:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564776; bh=RPsg4+ITmM9gFoQ7ZYe+JsyD9TMljUbzbnXkyjAN+G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i7rsVnzZNRbj8c9PpNiRg7tMJRfqPL27CBgh/2BYLhy+qMnsqAZ1SI3yukubMY6Pi AqeWgCRa9QCvNhT6DfZWACmnjtde1LUWdPnComt6Z0SC6DukGCv61sYaSpKPaMy5ED Tb2lkZz+jCZfbSru5IjhAQ3R7UyRWHJRoG2Q2d+ed2IFfP3HbrOknGR74/DblxShz3 HfDdHL6wK5w6kd2sjsm4mOfCT2YWLVhkmgSkGHrsJul0PrUtSR7Pu2lWRfyXHB0YpQ PxZjwhTXiv4YCQpcKbcz+qchBV/Gz6yINg7rEhGp0Z6vJJzYvYlsq9D0uJWB+wPLr8 ILHwZO3irzVsQ== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 43/45] tty: vt: document the rest of struct consw Date: Thu, 18 Jan 2024 08:57:54 +0100 Message-ID: <20240118075756.10541-44-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are still members of struct consw which are not documented yet. Fix that up, so we can generate kernel-doc for that struct. Signed-off-by: Jiri Slaby (SUSE) --- include/linux/console.h | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/include/linux/console.h b/include/linux/console.h index 698a2f7576b0..e0d5d84e918a 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -45,8 +45,11 @@ enum vc_intensity; /** * struct consw - callbacks for consoles * + * @owner: the module to get references of when this console is used + * @con_startup: set up the console and return its name (like VGA, EGA, ...) * @con_init: initialize the console on @vc. @init is true for the very first * call on this @vc. + * @con_deinit: deinitialize the console from @vc. * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. * (optional -- @con_putcs would be called instead) @@ -60,12 +63,33 @@ enum vc_intensity; * @con_blank: blank/unblank the console. The target mode is passed in @blank. * @mode_switch is set if changing from/to text/graphics. The hook * is supposed to return true if a redraw is needed. - * @con_set_palette: sets the palette of the console to @table (optional) + * @con_font_set: set console @vc font to @font with height @vpitch. @flags can + * be %KD_FONT_FLAG_DONT_RECALC. (optional) + * @con_font_get: fetch the current font on @vc of height @vpitch into @font. + * (optional) + * @con_font_default: set default font on @vc. @name can be %NULL or font name + * to search for. @font can be filled back. (optional) + * @con_resize: resize the @vc console to @width x @height. @from_user is true + * when this change comes from the user space. + * @con_set_palette: sets the palette of the console @vc to @table (optional) * @con_scrolldelta: the contents of the console should be scrolled by @lines. * Invoked by user. (optional) * @con_set_origin: set origin (see &vc_data::vc_origin) of the @vc. If not * provided or returns false, the origin is set to * @vc->vc_screenbuf. (optional) + * @con_save_screen: save screen content into @vc->vc_screenbuf. Called e.g. + * upon entering graphics. (optional) + * @con_build_attr: build attributes based on @color, @intensity and other + * parameters. The result is used for both normal and erase + * characters. (optional) + * @con_invert_region: invert a region of length @count on @vc starting at @p. + * (optional) + * @con_debug_enter: prepare the console for the debugger. This includes, but + * is not limited to, unblanking the console, loading an + * appropriate palette, and allowing debugger generated output. + * (optional) + * @con_debug_leave: restore the console to its pre-debug state as closely as + * possible. (optional) */ struct consw { struct module *owner; @@ -104,15 +128,7 @@ struct consw { enum vc_intensity intensity, bool blink, bool underline, bool reverse, bool italic); void (*con_invert_region)(struct vc_data *vc, u16 *p, int count); - /* - * Prepare the console for the debugger. This includes, but is not - * limited to, unblanking the console, loading an appropriate - * palette, and allowing debugger generated output. - */ void (*con_debug_enter)(struct vc_data *vc); - /* - * Restore the console to its pre-debug state as closely as possible. - */ void (*con_debug_leave)(struct vc_data *vc); }; From patchwork Thu Jan 18 07:57:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 765094 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34A6B35291; Thu, 18 Jan 2024 07:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564778; cv=none; b=eo1hxdVvP4jUxuHmp6rtJUNfPyFKxKcf9ZYf24apo/hgsxdOZs83LKVizpfoTUoIoOzXOGE/L+hbT2m6hlZddOuF8nTboNt9YkVkMvdfR76njxpnTw5mtoKwTqiJ29qK/FqrIfl2mrRHnJ4Ufr+nE7rJ5vF4Koc25nmg3F29qBU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564778; c=relaxed/simple; bh=sch2oSklySkkA5uKtgIFo49P/8fkBuU14RBK4x6PEBU=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=ETi4X8/tn685zd6cZWHBH1CFNwFSaCDx6B68dnzUxhM046deiCpPwUBAff3/GNADAmQ7wNTdwpzLUHalZucEF7ZVSUPstcXOnJeNNQUTF4O6AHe+SmsdEni/2G2+PD3l6XFOpzvP40pdHce4q3VHIDbPTvtUcXtG+q5O91U/pLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aEPYShIE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aEPYShIE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3CF4C43390; Thu, 18 Jan 2024 07:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564778; bh=sch2oSklySkkA5uKtgIFo49P/8fkBuU14RBK4x6PEBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aEPYShIE76jCj+iduQRivOTb09yxfqTVTSqr5ORmMOkMCTfOhC5uEdCl48+co51+F kHXx1EHOJoFu7L5XxQyTQh+bh1JII43MUMi00CnBHVSvmYe3yS6x0M4CEEMHgTrfF5 caJmj0QYayz73wDPVrOHF04dUQFTxMVl5C7BwodZoGZ7xot16aBBOava7BH92g07Hp Iim94CsF+B3D+FwbbhRR0E1AUiJXi6R7xlf+UP9W2NNvCYxoJ5m4zG7hdrjckv8NBo WOPmv1wgYSamFep6aK3I4PHzrHSi57FnB4rP5FAGimg5KXHRO4MvKYgH+eRdLPsRLG We3bbtudrbk2g== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 44/45] tty: vt: fix up kernel-doc Date: Thu, 18 Jan 2024 08:57:55 +0100 Message-ID: <20240118075756.10541-45-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 selection.c and vt.c still uses tabs in the kernel-doc. This misrenders the functions in the output -- sphinx misinterprets the description. So remove these tabs, incl. those around dashes. 'enum' keyword is needed before enum names. Fix that. Superfluous \n after the comments are also removed. They are not completely faulty, but this unifies all the kernel-doc in the files. Finally fix up the cross references. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/selection.c | 30 ++++++------- drivers/tty/vt/vt.c | 86 +++++++++++++++++++------------------- include/linux/console.h | 6 +-- 3 files changed, 62 insertions(+), 60 deletions(-) diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 34ee09f5a8f4..564341f1a74f 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -73,10 +73,12 @@ sel_pos(int n, bool unicode) } /** - * clear_selection - remove current selection + * clear_selection - remove current selection * - * Remove the current selection highlight, if any from the console - * holding the selection. The caller must hold the console lock. + * Remove the current selection highlight, if any from the console holding the + * selection. + * + * Locking: The caller must hold the console lock. */ void clear_selection(void) { @@ -110,13 +112,13 @@ static inline int inword(const u32 c) } /** - * sel_loadlut() - load the LUT table - * @lut: user table + * sel_loadlut() - load the LUT table + * @lut: user table * - * Load the LUT table from user space. Make a temporary copy so a partial - * update doesn't make a mess. + * Load the LUT table from user space. Make a temporary copy so a partial + * update doesn't make a mess. * - * Locking: The console lock is acquired. + * Locking: The console lock is acquired. */ int sel_loadlut(u32 __user *lut) { @@ -173,14 +175,14 @@ static int store_utf8(u32 c, char *p) } /** - * set_selection_user - set the current selection. - * @sel: user selection info - * @tty: the console tty + * set_selection_user - set the current selection. + * @sel: user selection info + * @tty: the console tty * - * Invoked by the ioctl handle for the vt layer. + * Invoked by the ioctl handle for the vt layer. * - * The entire selection process is managed under the console_lock. It's - * a lot under the lock but its hardly a performance path + * Locking: The entire selection process is managed under the console_lock. + * It's a lot under the lock but its hardly a performance path. */ int set_selection_user(const struct tiocl_selection __user *sel, struct tty_struct *tty) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 35d303017653..72d089b502fe 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1115,21 +1115,20 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, } /** - * vc_do_resize - resizing method for the tty - * @tty: tty being resized - * @vc: virtual console private data - * @cols: columns - * @lines: lines - * @from_user: invoked by a user? + * vc_do_resize - resizing method for the tty + * @tty: tty being resized + * @vc: virtual console private data + * @cols: columns + * @lines: lines + * @from_user: invoked by a user? * - * Resize a virtual console, clipping according to the actual constraints. - * If the caller passes a tty structure then update the termios winsize - * information and perform any necessary signal handling. + * Resize a virtual console, clipping according to the actual constraints. If + * the caller passes a tty structure then update the termios winsize + * information and perform any necessary signal handling. * - * Caller must hold the console semaphore. Takes the termios rwsem and - * ctrl.lock of the tty IFF a tty is passed. + * Locking: Caller must hold the console semaphore. Takes the termios rwsem and + * ctrl.lock of the tty IFF a tty is passed. */ - static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, unsigned int cols, unsigned int lines, bool from_user) { @@ -1277,16 +1276,17 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, } /** - * __vc_resize - resize a VT - * @vc: virtual console - * @cols: columns - * @rows: rows - * @from_user: invoked by a user? + * __vc_resize - resize a VT + * @vc: virtual console + * @cols: columns + * @rows: rows + * @from_user: invoked by a user? + * + * Resize a virtual console as seen from the console end of things. We use the + * common vc_do_resize() method to update the structures. * - * Resize a virtual console as seen from the console end of things. We - * use the common vc_do_resize methods to update the structures. The - * caller must hold the console sem to protect console internals and - * vc->port.tty + * Locking: The caller must hold the console sem to protect console internals + * and @vc->port.tty. */ int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows, bool from_user) @@ -1296,16 +1296,15 @@ int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows, EXPORT_SYMBOL(__vc_resize); /** - * vt_resize - resize a VT - * @tty: tty to resize - * @ws: winsize attributes + * vt_resize - resize a VT + * @tty: tty to resize + * @ws: winsize attributes * - * Resize a virtual terminal. This is called by the tty layer as we - * register our own handler for resizing. The mutual helper does all - * the actual work. + * Resize a virtual terminal. This is called by the tty layer as we register + * our own handler for resizing. The mutual helper does all the actual work. * - * Takes the console sem and the called methods then take the tty - * termios_rwsem and the tty ctrl.lock in that order. + * Locking: Takes the console sem and the called methods then take the tty + * termios_rwsem and the tty ctrl.lock in that order. */ static int vt_resize(struct tty_struct *tty, struct winsize *ws) { @@ -2647,8 +2646,8 @@ static inline int vc_translate_ascii(const struct vc_data *vc, int c) /** - * vc_sanitize_unicode - Replace invalid Unicode code points with U+FFFD - * @c: the received character, or U+FFFD for invalid sequences. + * vc_sanitize_unicode - Replace invalid Unicode code points with ``U+FFFD`` + * @c: the received character, or ``U+FFFD`` for invalid sequences. */ static inline int vc_sanitize_unicode(const int c) { @@ -2659,14 +2658,15 @@ static inline int vc_sanitize_unicode(const int c) } /** - * vc_translate_unicode - Combine UTF-8 into Unicode in @vc_utf_char + * vc_translate_unicode - Combine UTF-8 into Unicode in &vc_data.vc_utf_char * @vc: virtual console * @c: character to translate * @rescan: we return true if we need more (continuation) data * - * @vc_utf_char is the being-constructed unicode character. - * @vc_utf_count is the number of continuation bytes still expected to arrive. - * @vc_npar is the number of continuation bytes arrived so far. + * * &vc_data.vc_utf_char is the being-constructed unicode character. + * * &vc_data.vc_utf_count is the number of continuation bytes still expected to + * arrive. + * * &vc_data.vc_npar is the number of continuation bytes arrived so far. */ static int vc_translate_unicode(struct vc_data *vc, int c, bool *rescan) { @@ -3044,16 +3044,16 @@ struct tty_driver *console_driver; #ifdef CONFIG_VT_CONSOLE /** - * vt_kmsg_redirect() - Sets/gets the kernel message console - * @new: The new virtual terminal number or -1 if the console should stay - * unchanged + * vt_kmsg_redirect() - sets/gets the kernel message console + * @new: the new virtual terminal number or -1 if the console should stay + * unchanged * * By default, the kernel messages are always printed on the current virtual * console. However, the user may modify that default with the - * TIOCL_SETKMSGREDIRECT ioctl call. + * %TIOCL_SETKMSGREDIRECT ioctl call. * * This function sets the kernel message console to be @new. It returns the old - * virtual console number. The virtual terminal number 0 (both as parameter and + * virtual console number. The virtual terminal number %0 (both as parameter and * return value) means no redirection (i.e. always printed on the currently * active console). * @@ -3061,8 +3061,8 @@ struct tty_driver *console_driver; * value is not modified. You may use the macro vt_get_kmsg_redirect() in that * case to make the code more understandable. * - * When the kernel is compiled without CONFIG_VT_CONSOLE, this function ignores - * the parameter and always returns 0. + * When the kernel is compiled without %CONFIG_VT_CONSOLE, this function ignores + * the parameter and always returns %0. */ int vt_kmsg_redirect(int new) { @@ -3974,7 +3974,7 @@ static void vtconsole_deinit_device(struct con_driver *con) * RETURNS: zero if unbound, nonzero if bound * * Drivers can call this and if zero, they should release - * all resources allocated on con_startup() + * all resources allocated on &consw.con_startup() */ int con_is_bound(const struct consw *csw) { diff --git a/include/linux/console.h b/include/linux/console.h index e0d5d84e918a..b105675b7ec4 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -163,7 +163,7 @@ static inline void con_debug_leave(void) { } */ /** - * cons_flags - General console flags + * enum cons_flags - General console flags * @CON_PRINTBUFFER: Used by newly registered consoles to avoid duplicate * output of messages that were already shown by boot * consoles or read by userspace via syslog() syscall. @@ -244,7 +244,7 @@ struct nbcon_state { static_assert(sizeof(struct nbcon_state) <= sizeof(int)); /** - * nbcon_prio - console owner priority for nbcon consoles + * enum nbcon_prio - console owner priority for nbcon consoles * @NBCON_PRIO_NONE: Unused * @NBCON_PRIO_NORMAL: Normal (non-emergency) usage * @NBCON_PRIO_EMERGENCY: Emergency output (WARN/OOPS...) @@ -476,7 +476,7 @@ static inline bool console_is_registered(const struct console *con) * for_each_console() - Iterator over registered consoles * @con: struct console pointer used as loop cursor * - * The console list and the console->flags are immutable while iterating. + * The console list and the &console.flags are immutable while iterating. * * Requires console_list_lock to be held. */ From patchwork Thu Jan 18 07:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 763858 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C77C358A0; Thu, 18 Jan 2024 07:59:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564780; cv=none; b=VMeZGwhTA8u+22x1HntJ28wIU00a2/eKjdbu4++ZouvWrsfg0Cg3dYbaAwB924cWrCYJLskFsHtGjLiz9oBHD31qeLz12UKsPiDl12c2xUNtJDgqyPS1LxBb9IYzkWhztJ5GWjZu5KGCDq1+gzzoPnnlrIadE3l4SG5geAb1YFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705564780; c=relaxed/simple; bh=PNbtJZXcgSDfB9xk9l5CL+n1+oj48eBhvhkVHBH+k0w=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; b=D3fEU6V5v2RPWytUGQTCm16VjfKWmuQzk0tvSq+9OJtP7o1FD2T3AnqTrErscmt0ylwwFkZXT7+VkJRhRnM228sg5/rtwhlDayOQShRyc8DcfnwE9y8ZeLgHksIniZac22+td8uAZ6w4VCTOhQBjwDeuCz7TUCA/3TXLRUe1Bks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DanHzPYn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DanHzPYn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 871CEC433C7; Thu, 18 Jan 2024 07:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705564780; bh=PNbtJZXcgSDfB9xk9l5CL+n1+oj48eBhvhkVHBH+k0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DanHzPYnIPIyQKEaHce5925mI7xmyI4w5GjY06iMLwUrzL+BCQhU7THrVf2eljd2i 6s6YB+0EFr0/2fOVyv/haEaEyF+40kDkIKwVi6EKjUu25qvqSj0Bs7eHSF3olOpAKo OYc/eI1UJql7ge2e2KgXK+hYrPMG4c+AT3Lugkb3LR25e7C0Qtj7Okvm1I9wuuHzK6 RgFfZbWKgC3ZtvBzSi+MsrWru+4XRfieILTvqA2ihYl6OUDwd4tzuJEdZF8JmT9NfA SlCRr9af/BbyZPBfweNnMFZlbU651rLGAsj/0Do0H7GyNAFFfbyh1ny2MFkxXglt9H 9KosFpDlE0aig== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH 45/45] Documentation: add console.rst Date: Thu, 18 Jan 2024 08:57:56 +0100 Message-ID: <20240118075756.10541-46-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118075756.10541-1-jirislaby@kernel.org> References: <20240118075756.10541-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-serial@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now, that the console kernel-doc is in better shape, include it in the tty/ docs. It's not supernice, but it is what it is. At least for the beginning. Signed-off-by: Jiri Slaby (SUSE) Cc: Jonathan Corbet Cc: linux-doc@vger.kernel.org --- Documentation/driver-api/tty/console.rst | 45 ++++++++++++++++++++++++ Documentation/driver-api/tty/index.rst | 1 + 2 files changed, 46 insertions(+) create mode 100644 Documentation/driver-api/tty/console.rst diff --git a/Documentation/driver-api/tty/console.rst b/Documentation/driver-api/tty/console.rst new file mode 100644 index 000000000000..4348e36cd33b --- /dev/null +++ b/Documentation/driver-api/tty/console.rst @@ -0,0 +1,45 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======= +Console +======= + +.. contents:: :local: + +Struct Console +============== + +.. kernel-doc:: include/linux/console.h + :identifiers: console cons_flags + +Internals +--------- + +.. kernel-doc:: include/linux/console.h + :identifiers: nbcon_state nbcon_prio nbcon_context nbcon_write_context + +Struct Consw +============ + +.. kernel-doc:: include/linux/console.h + :identifiers: consw + +Console functions +================= + +.. kernel-doc:: include/linux/console.h + :identifiers: console_srcu_read_flags console_srcu_write_flags + console_is_registered for_each_console_srcu for_each_console + +.. kernel-doc:: drivers/tty/vt/selection.c + :export: +.. kernel-doc:: drivers/tty/vt/vt.c + :export: + +Internals +--------- + +.. kernel-doc:: drivers/tty/vt/selection.c + :internal: +.. kernel-doc:: drivers/tty/vt/vt.c + :internal: diff --git a/Documentation/driver-api/tty/index.rst b/Documentation/driver-api/tty/index.rst index b490da11f257..c1ffe3d1ec46 100644 --- a/Documentation/driver-api/tty/index.rst +++ b/Documentation/driver-api/tty/index.rst @@ -38,6 +38,7 @@ In-detail description of the named TTY structures is in separate documents: tty_buffer tty_ioctl tty_internals + console Writing TTY Driver ==================