* [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