vt: ioctl, switch VT_IS_IN_USE and VT_BUSY to inlines
These two were macros. Switch them to static inlines, so that it's more understandable what they are doing. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219073951.16151-2-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
dce05aa6ee
commit
e587e8f174
|
@ -40,10 +40,25 @@
|
||||||
#include <linux/selection.h>
|
#include <linux/selection.h>
|
||||||
|
|
||||||
char vt_dont_switch;
|
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)
|
static inline bool vt_in_use(unsigned int i)
|
||||||
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_is_sel(vc_cons[i].d))
|
{
|
||||||
|
extern struct tty_driver *console_driver;
|
||||||
|
|
||||||
|
return console_driver->ttys[i] && console_driver->ttys[i]->count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool vt_busy(int i)
|
||||||
|
{
|
||||||
|
if (vt_in_use(i))
|
||||||
|
return true;
|
||||||
|
if (i == fg_console)
|
||||||
|
return true;
|
||||||
|
if (vc_is_sel(vc_cons[i].d))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Console (vt and kd) routines, as defined by USL SVR4 manual, and by
|
* Console (vt and kd) routines, as defined by USL SVR4 manual, and by
|
||||||
|
@ -289,7 +304,7 @@ static int vt_disallocate(unsigned int vc_num)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
console_lock();
|
console_lock();
|
||||||
if (VT_BUSY(vc_num))
|
if (vt_busy(vc_num))
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
else if (vc_num)
|
else if (vc_num)
|
||||||
vc = vc_deallocate(vc_num);
|
vc = vc_deallocate(vc_num);
|
||||||
|
@ -311,7 +326,7 @@ static void vt_disallocate_all(void)
|
||||||
|
|
||||||
console_lock();
|
console_lock();
|
||||||
for (i = 1; i < MAX_NR_CONSOLES; i++)
|
for (i = 1; i < MAX_NR_CONSOLES; i++)
|
||||||
if (!VT_BUSY(i))
|
if (!vt_busy(i))
|
||||||
vc[i] = vc_deallocate(i);
|
vc[i] = vc_deallocate(i);
|
||||||
else
|
else
|
||||||
vc[i] = NULL;
|
vc[i] = NULL;
|
||||||
|
@ -648,7 +663,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
state = 1; /* /dev/tty0 is always open */
|
state = 1; /* /dev/tty0 is always open */
|
||||||
for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
|
for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
|
||||||
++i, mask <<= 1)
|
++i, mask <<= 1)
|
||||||
if (VT_IS_IN_USE(i))
|
if (vt_in_use(i))
|
||||||
state |= mask;
|
state |= mask;
|
||||||
ret = put_user(state, &vtstat->v_state);
|
ret = put_user(state, &vtstat->v_state);
|
||||||
}
|
}
|
||||||
|
@ -661,7 +676,7 @@ int vt_ioctl(struct tty_struct *tty,
|
||||||
case VT_OPENQRY:
|
case VT_OPENQRY:
|
||||||
/* FIXME: locking ? - but then this is a stupid API */
|
/* FIXME: locking ? - but then this is a stupid API */
|
||||||
for (i = 0; i < MAX_NR_CONSOLES; ++i)
|
for (i = 0; i < MAX_NR_CONSOLES; ++i)
|
||||||
if (! VT_IS_IN_USE(i))
|
if (!vt_in_use(i))
|
||||||
break;
|
break;
|
||||||
uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
|
uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
|
||||||
goto setint;
|
goto setint;
|
||||||
|
|
Loading…
Reference in New Issue