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>
Fri, 21 Feb 2020 09:31:18 +0000 (10:31 +0100)
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 78732feaf65bc237ccf26fb4685198e957e6a1c1..f3ec0037a0e341cd934099071e8917bdbd69e2c0 100644 (file)
@@ -84,6 +84,11 @@ void clear_selection(void)
 }
 EXPORT_SYMBOL_GPL(clear_selection);
 
+bool vc_is_sel(struct vc_data *vc)
+{
+       return vc == sel_cons;
+}
+
 /*
  * User settable table: what characters are to be considered alphabetic?
  * 128 bits. Locked by the console lock.
index 35d21cdb60d0b82b0c786c235b7b873409efc774..a2bbff60299906997a2d9f1b6c8fb4ec97938486 100644 (file)
@@ -890,8 +890,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);
 }
@@ -901,7 +902,7 @@ static void set_cursor(struct vc_data *vc)
        if (!con_is_fg(vc) || console_blanked || 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)
@@ -1196,7 +1197,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
                }
        }
 
-       if (vc == sel_cons)
+       if (vc_is_sel(vc))
                clear_selection();
 
        old_rows = vc->vc_rows;
index 8b0ed139592f95bf4c42fdfbd88273dec874372e..dc8c5a34f8eb2d4236378f2ce22e46effdb9a776 100644 (file)
@@ -43,7 +43,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 e2c1f96bf059b5ab71f59c66d83e36b8e386b6b0..5b890ef5b59facfbcc5d8ebfaf6ead2c26c54dee 100644 (file)
@@ -11,8 +11,8 @@
 #include <linux/tiocl.h>
 #include <linux/vt_buffer.h>
 
-extern struct vc_data *sel_cons;
 struct tty_struct;
+struct vc_data;
 
 extern void clear_selection(void);
 extern int set_selection_user(const struct tiocl_selection __user *sel,
@@ -24,6 +24,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 const unsigned char color_table[];