* [PATCH 1/4] tty: vt: reformat tioclinux()
@ 2023-04-20 9:35 Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 2/4] tty: vt: simplify some cases in tioclinux() Jiri Slaby (SUSE)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-04-20 9:35 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Jiri Slaby (SUSE)
Reformat tioclinux() to what we are used to. That is:
* format switch-case (one less indent level),
* format comments (the same indent level), and
* add a newline before return.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/vt/vt.c | 167 ++++++++++++++++++++++----------------------
1 file changed, 84 insertions(+), 83 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 40e4928eddaf..2dffee1e114a 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3143,93 +3143,94 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
return -EFAULT;
ret = 0;
- switch (type)
- {
- case TIOCL_SETSEL:
- ret = set_selection_user((struct tiocl_selection
- __user *)(p+1), tty);
- break;
- case TIOCL_PASTESEL:
- ret = paste_selection(tty);
- break;
- case TIOCL_UNBLANKSCREEN:
- console_lock();
- unblank_screen();
- console_unlock();
- break;
- case TIOCL_SELLOADLUT:
- console_lock();
- ret = sel_loadlut(p);
- console_unlock();
- break;
- case TIOCL_GETSHIFTSTATE:
-
- /*
- * Make it possible to react to Shift+Mousebutton.
- * Note that 'shift_state' is an undocumented
- * kernel-internal variable; programs not closely
- * related to the kernel should not use this.
- */
- data = vt_get_shift_state();
- ret = put_user(data, p);
- break;
- case TIOCL_GETMOUSEREPORTING:
- console_lock(); /* May be overkill */
- data = mouse_reporting();
- console_unlock();
- ret = put_user(data, p);
- break;
- case TIOCL_SETVESABLANK:
- console_lock();
- ret = set_vesa_blanking(p);
- console_unlock();
- break;
- case TIOCL_GETKMSGREDIRECT:
- data = vt_get_kmsg_redirect();
- ret = put_user(data, p);
- break;
- case TIOCL_SETKMSGREDIRECT:
- if (!capable(CAP_SYS_ADMIN)) {
- ret = -EPERM;
- } else {
- if (get_user(data, p+1))
- ret = -EFAULT;
- else
- vt_kmsg_redirect(data);
- }
- break;
- case TIOCL_GETFGCONSOLE:
- /* No locking needed as this is a transiently
- correct return anyway if the caller hasn't
- disabled switching */
- ret = fg_console;
- break;
- case TIOCL_SCROLLCONSOLE:
- if (get_user(lines, (s32 __user *)(p+4))) {
+ switch (type) {
+ case TIOCL_SETSEL:
+ ret = set_selection_user((struct tiocl_selection
+ __user *)(p+1), tty);
+ break;
+ case TIOCL_PASTESEL:
+ ret = paste_selection(tty);
+ break;
+ case TIOCL_UNBLANKSCREEN:
+ console_lock();
+ unblank_screen();
+ console_unlock();
+ break;
+ case TIOCL_SELLOADLUT:
+ console_lock();
+ ret = sel_loadlut(p);
+ console_unlock();
+ break;
+ case TIOCL_GETSHIFTSTATE:
+ /*
+ * Make it possible to react to Shift+Mousebutton. Note that
+ * 'shift_state' is an undocumented kernel-internal variable;
+ * programs not closely related to the kernel should not use
+ * this.
+ */
+ data = vt_get_shift_state();
+ ret = put_user(data, p);
+ break;
+ case TIOCL_GETMOUSEREPORTING:
+ console_lock(); /* May be overkill */
+ data = mouse_reporting();
+ console_unlock();
+ ret = put_user(data, p);
+ break;
+ case TIOCL_SETVESABLANK:
+ console_lock();
+ ret = set_vesa_blanking(p);
+ console_unlock();
+ break;
+ case TIOCL_GETKMSGREDIRECT:
+ data = vt_get_kmsg_redirect();
+ ret = put_user(data, p);
+ break;
+ case TIOCL_SETKMSGREDIRECT:
+ if (!capable(CAP_SYS_ADMIN)) {
+ ret = -EPERM;
+ } else {
+ if (get_user(data, p+1))
ret = -EFAULT;
- } else {
- /* Need the console lock here. Note that lots
- of other calls need fixing before the lock
- is actually useful ! */
- console_lock();
- scrollfront(vc_cons[fg_console].d, lines);
- console_unlock();
- ret = 0;
- }
- break;
- case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
+ else
+ vt_kmsg_redirect(data);
+ }
+ break;
+ case TIOCL_GETFGCONSOLE:
+ /*
+ * No locking needed as this is a transiently correct return
+ * anyway if the caller hasn't disabled switching.
+ */
+ ret = fg_console;
+ break;
+ case TIOCL_SCROLLCONSOLE:
+ if (get_user(lines, (s32 __user *)(p+4))) {
+ ret = -EFAULT;
+ } else {
+ /*
+ * Needs the console lock here. Note that lots of other
+ * calls need fixing before the lock is actually useful!
+ */
console_lock();
- ignore_poke = 1;
- do_blank_screen(0);
+ scrollfront(vc_cons[fg_console].d, lines);
console_unlock();
- break;
- case TIOCL_BLANKEDSCREEN:
- ret = console_blanked;
- break;
- default:
- ret = -EINVAL;
- break;
+ ret = 0;
+ }
+ break;
+ case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
+ console_lock();
+ ignore_poke = 1;
+ do_blank_screen(0);
+ console_unlock();
+ break;
+ case TIOCL_BLANKEDSCREEN:
+ ret = console_blanked;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
}
+
return ret;
}
--
2.40.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] tty: vt: simplify some cases in tioclinux()
2023-04-20 9:35 [PATCH 1/4] tty: vt: reformat tioclinux() Jiri Slaby (SUSE)
@ 2023-04-20 9:35 ` Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 3/4] tty: vt: distribute EXPORT_SYMBOL() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 4/4] tty: vt: drop checks for undefined VT_SINGLE_DRIVER Jiri Slaby (SUSE)
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-04-20 9:35 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Jiri Slaby (SUSE)
There is no need to set "ret" variable and break. We can simply return
from the cases. This makes the code much easier to follow, as many else
branches are redundant.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/vt/vt.c | 62 +++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 36 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 2dffee1e114a..f44d5b8a102c 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -3145,12 +3145,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
switch (type) {
case TIOCL_SETSEL:
- ret = set_selection_user((struct tiocl_selection
+ return set_selection_user((struct tiocl_selection
__user *)(p+1), tty);
- break;
case TIOCL_PASTESEL:
- ret = paste_selection(tty);
- break;
+ return paste_selection(tty);
case TIOCL_UNBLANKSCREEN:
console_lock();
unblank_screen();
@@ -3169,14 +3167,12 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
* this.
*/
data = vt_get_shift_state();
- ret = put_user(data, p);
- break;
+ return put_user(data, p);
case TIOCL_GETMOUSEREPORTING:
console_lock(); /* May be overkill */
data = mouse_reporting();
console_unlock();
- ret = put_user(data, p);
- break;
+ return put_user(data, p);
case TIOCL_SETVESABLANK:
console_lock();
ret = set_vesa_blanking(p);
@@ -3184,38 +3180,34 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
break;
case TIOCL_GETKMSGREDIRECT:
data = vt_get_kmsg_redirect();
- ret = put_user(data, p);
- break;
+ return put_user(data, p);
case TIOCL_SETKMSGREDIRECT:
- if (!capable(CAP_SYS_ADMIN)) {
- ret = -EPERM;
- } else {
- if (get_user(data, p+1))
- ret = -EFAULT;
- else
- vt_kmsg_redirect(data);
- }
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ if (get_user(data, p+1))
+ return -EFAULT;
+
+ vt_kmsg_redirect(data);
+
break;
case TIOCL_GETFGCONSOLE:
/*
* No locking needed as this is a transiently correct return
* anyway if the caller hasn't disabled switching.
*/
- ret = fg_console;
- break;
+ return fg_console;
case TIOCL_SCROLLCONSOLE:
- if (get_user(lines, (s32 __user *)(p+4))) {
- ret = -EFAULT;
- } else {
- /*
- * Needs the console lock here. Note that lots of other
- * calls need fixing before the lock is actually useful!
- */
- console_lock();
- scrollfront(vc_cons[fg_console].d, lines);
- console_unlock();
- ret = 0;
- }
+ if (get_user(lines, (s32 __user *)(p+4)))
+ return -EFAULT;
+
+ /*
+ * Needs the console lock here. Note that lots of other calls
+ * need fixing before the lock is actually useful!
+ */
+ console_lock();
+ scrollfront(vc_cons[fg_console].d, lines);
+ console_unlock();
break;
case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */
console_lock();
@@ -3224,11 +3216,9 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
console_unlock();
break;
case TIOCL_BLANKEDSCREEN:
- ret = console_blanked;
- break;
+ return console_blanked;
default:
- ret = -EINVAL;
- break;
+ return -EINVAL;
}
return ret;
--
2.40.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/4] tty: vt: distribute EXPORT_SYMBOL()
2023-04-20 9:35 [PATCH 1/4] tty: vt: reformat tioclinux() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 2/4] tty: vt: simplify some cases in tioclinux() Jiri Slaby (SUSE)
@ 2023-04-20 9:35 ` Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 4/4] tty: vt: drop checks for undefined VT_SINGLE_DRIVER Jiri Slaby (SUSE)
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-04-20 9:35 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Jiri Slaby (SUSE)
There is a list of EXPORT_SYMBOL()s at the end of the file. Put them all
by their definition. This is how we usually do that.
give_up_console() lost its VT_SINGLE_DRIVER local ifndef protection as
that whole code is under this check.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/vt/vt.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index f44d5b8a102c..c4d333277ef7 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -135,6 +135,7 @@ const struct consw *conswitchp;
#define DEFAULT_CURSOR_BLINK_MS 200
struct vc vc_cons [MAX_NR_CONSOLES];
+EXPORT_SYMBOL(vc_cons);
#ifndef VT_SINGLE_DRIVER
static const struct consw *con_driver_map[MAX_NR_CONSOLES];
@@ -162,6 +163,7 @@ int default_utf8 = true;
module_param(default_utf8, int, S_IRUGO | S_IWUSR);
int global_cursor_default = -1;
module_param(global_cursor_default, int, S_IRUGO | S_IWUSR);
+EXPORT_SYMBOL(global_cursor_default);
static int cur_default = CUR_UNDERLINE;
module_param(cur_default, int, S_IRUGO | S_IWUSR);
@@ -174,6 +176,7 @@ static int ignore_poke;
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 int vesa_off_interval;
@@ -190,8 +193,10 @@ static DECLARE_WORK(con_driver_unregister_work, con_driver_unregister_callback);
* saved_* variants are for save/restore around kernel debugger enter/leave
*/
int fg_console;
+EXPORT_SYMBOL(fg_console);
int last_console;
int want_console = -1;
+
static int saved_fg_console;
static int saved_last_console;
static int saved_want_console;
@@ -223,6 +228,7 @@ static int scrollback_delta;
* the console on our behalf.
*/
int (*console_blank_hook)(int);
+EXPORT_SYMBOL(console_blank_hook);
static DEFINE_TIMER(console_timer, blank_screen_t);
static int blank_state;
@@ -639,6 +645,7 @@ void update_region(struct vc_data *vc, unsigned long start, int count)
set_cursor(vc);
}
}
+EXPORT_SYMBOL(update_region);
/* Structure of attributes is hardware-dependent */
@@ -984,6 +991,7 @@ void redraw_screen(struct vc_data *vc, int is_switch)
notify_update(vc);
}
}
+EXPORT_SYMBOL(redraw_screen);
/*
* Allocation, freeing and resizing of VTs.
@@ -1305,6 +1313,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows)
{
return vc_do_resize(vc->port.tty, vc, cols, rows);
}
+EXPORT_SYMBOL(vc_resize);
/**
* vt_resize - resize a VT
@@ -1368,6 +1377,7 @@ enum { EPecma = 0, EPdec, EPeq, EPgt, EPlt};
const unsigned char color_table[] = { 0, 4, 2, 6, 1, 5, 3, 7,
8,12,10,14, 9,13,11,15 };
+EXPORT_SYMBOL(color_table);
/* the default colour table, for VGA+ colour systems */
unsigned char default_red[] = {
@@ -1375,18 +1385,21 @@ unsigned char default_red[] = {
0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff
};
module_param_array(default_red, byte, NULL, S_IRUGO | S_IWUSR);
+EXPORT_SYMBOL(default_red);
unsigned char default_grn[] = {
0x00, 0x00, 0xaa, 0x55, 0x00, 0x00, 0xaa, 0xaa,
0x55, 0x55, 0xff, 0xff, 0x55, 0x55, 0xff, 0xff
};
module_param_array(default_grn, byte, NULL, S_IRUGO | S_IWUSR);
+EXPORT_SYMBOL(default_grn);
unsigned char default_blu[] = {
0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa,
0x55, 0x55, 0x55, 0x55, 0xff, 0xff, 0xff, 0xff
};
module_param_array(default_blu, byte, NULL, S_IRUGO | S_IWUSR);
+EXPORT_SYMBOL(default_blu);
/*
* gotoxy() must verify all boundaries, because the arguments
@@ -4227,6 +4240,7 @@ void give_up_console(const struct consw *csw)
do_unregister_con_driver(csw);
console_unlock();
}
+EXPORT_SYMBOL(give_up_console);
static int __init vtconsole_class_init(void)
{
@@ -4783,23 +4797,3 @@ void vc_scrolldelta_helper(struct vc_data *c, int lines,
c->vc_visible_origin = ubase + (from + from_off) % wrap;
}
EXPORT_SYMBOL_GPL(vc_scrolldelta_helper);
-
-/*
- * Visible symbols for modules
- */
-
-EXPORT_SYMBOL(color_table);
-EXPORT_SYMBOL(default_red);
-EXPORT_SYMBOL(default_grn);
-EXPORT_SYMBOL(default_blu);
-EXPORT_SYMBOL(update_region);
-EXPORT_SYMBOL(redraw_screen);
-EXPORT_SYMBOL(vc_resize);
-EXPORT_SYMBOL(fg_console);
-EXPORT_SYMBOL(console_blank_hook);
-EXPORT_SYMBOL(console_blanked);
-EXPORT_SYMBOL(vc_cons);
-EXPORT_SYMBOL(global_cursor_default);
-#ifndef VT_SINGLE_DRIVER
-EXPORT_SYMBOL(give_up_console);
-#endif
--
2.40.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 4/4] tty: vt: drop checks for undefined VT_SINGLE_DRIVER
2023-04-20 9:35 [PATCH 1/4] tty: vt: reformat tioclinux() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 2/4] tty: vt: simplify some cases in tioclinux() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 3/4] tty: vt: distribute EXPORT_SYMBOL() Jiri Slaby (SUSE)
@ 2023-04-20 9:35 ` Jiri Slaby (SUSE)
2 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-04-20 9:35 UTC (permalink / raw)
To: gregkh; +Cc: linux-kernel, Jiri Slaby (SUSE)
VT_SINGLE_DRIVER is defined nowhere. Remove its checks. These were added
long time ago and never used.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/vt/vt.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index c4d333277ef7..1e8e57b45688 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -137,9 +137,7 @@ const struct consw *conswitchp;
struct vc vc_cons [MAX_NR_CONSOLES];
EXPORT_SYMBOL(vc_cons);
-#ifndef VT_SINGLE_DRIVER
static const struct consw *con_driver_map[MAX_NR_CONSOLES];
-#endif
static int con_open(struct tty_struct *, struct file *);
static void vc_init(struct vc_data *vc, unsigned int rows,
@@ -1008,10 +1006,10 @@ static void visual_init(struct vc_data *vc, int num, int init)
if (vc->vc_sw)
module_put(vc->vc_sw->owner);
vc->vc_sw = conswitchp;
-#ifndef VT_SINGLE_DRIVER
+
if (con_driver_map[num])
vc->vc_sw = con_driver_map[num];
-#endif
+
__module_get(vc->vc_sw->owner);
vc->vc_num = num;
vc->vc_display_fg = &master_display_fg;
@@ -3575,8 +3573,6 @@ int __init vty_init(const struct file_operations *console_fops)
return 0;
}
-#ifndef VT_SINGLE_DRIVER
-
static struct class *vtconsole_class;
static int do_bind_con_driver(const struct consw *csw, int first, int last,
@@ -4278,8 +4274,6 @@ static int __init vtconsole_class_init(void)
}
postcore_initcall(vtconsole_class_init);
-#endif
-
/*
* Screen blanking
*/
--
2.40.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-20 9:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 9:35 [PATCH 1/4] tty: vt: reformat tioclinux() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 2/4] tty: vt: simplify some cases in tioclinux() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 3/4] tty: vt: distribute EXPORT_SYMBOL() Jiri Slaby (SUSE)
2023-04-20 9:35 ` [PATCH 4/4] tty: vt: drop checks for undefined VT_SINGLE_DRIVER Jiri Slaby (SUSE)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®