vt: selection, introduce vc_is_sel
authorJiri Slaby <jslaby@suse.cz>
Wed, 19 Feb 2020 07:39:43 +0000 (08:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2020 17:02:39 +0000 (19:02 +0200)
commit dce05aa6eec977f1472abed95ccd71276b9a3864 upstream.

Avoid global variables (namely sel_cons) by introducing vc_is_sel. It
checks whether the parameter is the current selection console. This will
help putting sel_cons to a struct later.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20200219073951.16151-1-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/selection.c
drivers/tty/vt/vt.c
drivers/tty/vt/vt_ioctl.c
include/linux/selection.h

index 9dae02ce4092bf605756683d318c96ea7765f241..4dafe2871d41a6db8319d35b5bf13f4f72ffee86 100644 (file)
@@ -80,6 +80,11 @@ void clear_selection(void)
        }
 }
 
+bool vc_is_sel(struct vc_data *vc)
+{
+       return vc == sel_cons;
+}
+
 /*
  * User settable table: what characters are to be considered alphabetic?
  * 256 bits. Locked by the console lock.
index 5b8b6ebebf3efe0a263bfe55f060081cf29a933d..983cce3d02a7260f9f7cc82ab22ac78fa29969b7 100644 (file)
@@ -600,8 +600,9 @@ static void hide_softcursor(struct vc_data *vc)
 
 static void hide_cursor(struct vc_data *vc)
 {
-       if (vc == sel_cons)
+       if (vc_is_sel(vc))
                clear_selection();
+
        vc->vc_sw->con_cursor(vc, CM_ERASE);
        hide_softcursor(vc);
 }
@@ -612,7 +613,7 @@ static void set_cursor(struct vc_data *vc)
            vc->vc_mode == KD_GRAPHICS)
                return;
        if (vc->vc_deccm) {
-               if (vc == sel_cons)
+               if (vc_is_sel(vc))
                        clear_selection();
                add_softcursor(vc);
                if ((vc->vc_cursor_type & 0x0f) != 1)
@@ -878,7 +879,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
        if (!newscreen)
                return -ENOMEM;
 
-       if (vc == sel_cons)
+       if (vc_is_sel(vc))
                clear_selection();
 
        old_rows = vc->vc_rows;
index e9d9f9f3dc8865651abae72b07f47cf2b6b1df20..06595ae620a02a48c3e9e1aff299f4f0035e0091 100644 (file)
@@ -42,7 +42,7 @@ char vt_dont_switch;
 extern struct tty_driver *console_driver;
 
 #define VT_IS_IN_USE(i)        (console_driver->ttys[i] && console_driver->ttys[i]->count)
-#define VT_BUSY(i)     (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
+#define VT_BUSY(i)     (VT_IS_IN_USE(i) || i == fg_console || vc_is_sel(vc_cons[i].d))
 
 /*
  * Console (vt and kd) routines, as defined by USL SVR4 manual, and by
index 85193aa8c1e3db14d4cbc77c4c398bc4ed94a5d0..ca3d9513b5ac7aed5d506a7a457a671204ffde0f 100644 (file)
@@ -12,8 +12,8 @@
 
 struct tty_struct;
 
-extern struct vc_data *sel_cons;
 struct tty_struct;
+struct vc_data;
 
 extern void clear_selection(void);
 extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty);
@@ -22,6 +22,8 @@ extern int sel_loadlut(char __user *p);
 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);
+
 extern int console_blanked;
 
 extern unsigned char color_table[];