tty: vt: pass vc_resize_user as a parameter
It is pretty unfortunate to set vc_data::vc_resize_user in two callers of vc_do_resize(). vc_resize_user is immediately reset there (while remembering it). So instead of this back and forth, pass 'from_user' as a parameter. Notes on 'int user': * The name changes from 'user' to 'from_user' on some places to be consistent. * The type is bool now as 'int user' might evoke user's uid or whatever. Provided vc_resize() is called on many places and they need not to care about this parameter, its prototype is kept unchanged. Instead, it is now an inline calling a new __vc_resize() which implements the above. This patch makes the situation much more obvious. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Helge Deller <deller@gmx.de> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Tested-by: Helge Deller <deller@gmx.de> # parisc STI console Link: https://lore.kernel.org/r/20240122110401.7289-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d321cd13f6
commit
beccdcfa15
@ -1115,13 +1115,13 @@ err_free:
|
||||
}
|
||||
|
||||
static inline int resize_screen(struct vc_data *vc, int width, int height,
|
||||
int user)
|
||||
bool from_user)
|
||||
{
|
||||
/* Resizes the resolution of the display adapater */
|
||||
int err = 0;
|
||||
|
||||
if (vc->vc_sw->con_resize)
|
||||
err = vc->vc_sw->con_resize(vc, width, height, user);
|
||||
err = vc->vc_sw->con_resize(vc, width, height, from_user);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -1132,6 +1132,7 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
|
||||
* @vc: virtual console private data
|
||||
* @cols: columns
|
||||
* @lines: lines
|
||||
* @from_user: invoked by a user?
|
||||
*
|
||||
* Resize a virtual console, clipping according to the actual constraints.
|
||||
* If the caller passes a tty structure then update the termios winsize
|
||||
@ -1142,21 +1143,17 @@ static inline int resize_screen(struct vc_data *vc, int width, int height,
|
||||
*/
|
||||
|
||||
static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
|
||||
unsigned int cols, unsigned int lines)
|
||||
unsigned int cols, unsigned int lines, bool from_user)
|
||||
{
|
||||
unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0;
|
||||
unsigned long end;
|
||||
unsigned int old_rows, old_row_size, first_copied_row;
|
||||
unsigned int new_cols, new_rows, new_row_size, new_screen_size;
|
||||
unsigned int user;
|
||||
unsigned short *oldscreen, *newscreen;
|
||||
u32 **new_uniscr = NULL;
|
||||
|
||||
WARN_CONSOLE_UNLOCKED();
|
||||
|
||||
user = vc->vc_resize_user;
|
||||
vc->vc_resize_user = 0;
|
||||
|
||||
if (cols > VC_MAXCOL || lines > VC_MAXROW)
|
||||
return -EINVAL;
|
||||
|
||||
@ -1182,7 +1179,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
|
||||
* to deal with possible errors from the code below, we call
|
||||
* the resize_screen here as well.
|
||||
*/
|
||||
return resize_screen(vc, new_cols, new_rows, user);
|
||||
return resize_screen(vc, new_cols, new_rows, from_user);
|
||||
}
|
||||
|
||||
if (new_screen_size > KMALLOC_MAX_SIZE || !new_screen_size)
|
||||
@ -1205,7 +1202,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
|
||||
old_rows = vc->vc_rows;
|
||||
old_row_size = vc->vc_size_row;
|
||||
|
||||
err = resize_screen(vc, new_cols, new_rows, user);
|
||||
err = resize_screen(vc, new_cols, new_rows, from_user);
|
||||
if (err) {
|
||||
kfree(newscreen);
|
||||
vc_uniscr_free(new_uniscr);
|
||||
@ -1292,22 +1289,23 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
|
||||
}
|
||||
|
||||
/**
|
||||
* vc_resize - resize a VT
|
||||
* __vc_resize - resize a VT
|
||||
* @vc: virtual console
|
||||
* @cols: columns
|
||||
* @rows: rows
|
||||
* @from_user: invoked by a user?
|
||||
*
|
||||
* Resize a virtual console as seen from the console end of things. We
|
||||
* use the common vc_do_resize methods to update the structures. The
|
||||
* caller must hold the console sem to protect console internals and
|
||||
* vc->port.tty
|
||||
*/
|
||||
|
||||
int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows)
|
||||
int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows,
|
||||
bool from_user)
|
||||
{
|
||||
return vc_do_resize(vc->port.tty, vc, cols, rows);
|
||||
return vc_do_resize(vc->port.tty, vc, cols, rows, from_user);
|
||||
}
|
||||
EXPORT_SYMBOL(vc_resize);
|
||||
EXPORT_SYMBOL(__vc_resize);
|
||||
|
||||
/**
|
||||
* vt_resize - resize a VT
|
||||
@ -1327,7 +1325,7 @@ static int vt_resize(struct tty_struct *tty, struct winsize *ws)
|
||||
int ret;
|
||||
|
||||
console_lock();
|
||||
ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row);
|
||||
ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row, false);
|
||||
console_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
@ -714,8 +714,7 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs)
|
||||
vcp->vc_scan_lines = v.v_vlin;
|
||||
if (v.v_clin)
|
||||
vcp->vc_cell_height = v.v_clin;
|
||||
vcp->vc_resize_user = 1;
|
||||
ret = vc_resize(vcp, v.v_cols, v.v_rows);
|
||||
ret = __vc_resize(vcp, v.v_cols, v.v_rows, true);
|
||||
if (ret) {
|
||||
vcp->vc_scan_lines = save_scan_lines;
|
||||
vcp->vc_cell_height = save_cell_height;
|
||||
@ -923,9 +922,8 @@ int vt_ioctl(struct tty_struct *tty,
|
||||
vc = vc_cons[i].d;
|
||||
|
||||
if (vc) {
|
||||
vc->vc_resize_user = 1;
|
||||
/* FIXME: review v tty lock */
|
||||
vc_resize(vc_cons[i].d, cc, ll);
|
||||
__vc_resize(vc_cons[i].d, cc, ll, true);
|
||||
}
|
||||
}
|
||||
console_unlock();
|
||||
|
@ -1081,12 +1081,12 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font, unsigne
|
||||
}
|
||||
|
||||
static int vgacon_resize(struct vc_data *c, unsigned int width,
|
||||
unsigned int height, unsigned int user)
|
||||
unsigned int height, bool from_user)
|
||||
{
|
||||
if ((width << 1) * height > vga_vram_size)
|
||||
return -EINVAL;
|
||||
|
||||
if (user) {
|
||||
if (from_user) {
|
||||
/*
|
||||
* Ho ho! Someone (svgatextmode, eh?) may have reprogrammed
|
||||
* the video mode! Set the new defaults then and go away.
|
||||
|
@ -1996,7 +1996,7 @@ static void updatescrollmode(struct fbcon_display *p,
|
||||
#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */
|
||||
|
||||
static int fbcon_resize(struct vc_data *vc, unsigned int width,
|
||||
unsigned int height, unsigned int user)
|
||||
unsigned int height, bool from_user)
|
||||
{
|
||||
struct fb_info *info = fbcon_info_from_console(vc->vc_num);
|
||||
struct fbcon_ops *ops = info->fbcon_par;
|
||||
|
@ -66,7 +66,7 @@ struct consw {
|
||||
int (*con_font_default)(struct vc_data *vc,
|
||||
struct console_font *font, char *name);
|
||||
int (*con_resize)(struct vc_data *vc, unsigned int width,
|
||||
unsigned int height, unsigned int user);
|
||||
unsigned int height, bool from_user);
|
||||
void (*con_set_palette)(struct vc_data *vc,
|
||||
const unsigned char *table);
|
||||
void (*con_scrolldelta)(struct vc_data *vc, int lines);
|
||||
|
@ -151,7 +151,6 @@ struct vc_data {
|
||||
DECLARE_BITMAP(vc_tab_stop, VC_TABSTOPS_COUNT); /* Tab stops. 256 columns. */
|
||||
unsigned char vc_palette[16*3]; /* Colour palette for VGA+ */
|
||||
unsigned short * vc_translate;
|
||||
unsigned int vc_resize_user; /* resize request from user */
|
||||
unsigned int vc_bell_pitch; /* Console bell pitch */
|
||||
unsigned int vc_bell_duration; /* Console bell duration */
|
||||
unsigned short vc_cur_blink_ms; /* Cursor blink duration */
|
||||
|
@ -25,7 +25,8 @@ extern int fg_console, last_console, want_console;
|
||||
|
||||
int vc_allocate(unsigned int console);
|
||||
int vc_cons_allocated(unsigned int console);
|
||||
int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines);
|
||||
int __vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines,
|
||||
bool from_user);
|
||||
struct vc_data *vc_deallocate(unsigned int console);
|
||||
void reset_palette(struct vc_data *vc);
|
||||
void do_blank_screen(int entering_gfx);
|
||||
@ -42,6 +43,12 @@ void redraw_screen(struct vc_data *vc, int is_switch);
|
||||
#define update_screen(x) redraw_screen(x, 0)
|
||||
#define switch_screen(x) redraw_screen(x, 1)
|
||||
|
||||
static inline int vc_resize(struct vc_data *vc, unsigned int cols,
|
||||
unsigned int lines)
|
||||
{
|
||||
return __vc_resize(vc, cols, lines, false);
|
||||
}
|
||||
|
||||
struct tty_struct;
|
||||
int tioclinux(struct tty_struct *tty, unsigned long arg);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user