Commit 63c4f92f authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

tty/vt: consolemap: extract con_allocate_new() from con_do_clear_unimap()



The first part of con_do_clear_unimap() is needed on another place, so
extract it to a separate function called con_allocate_new(). It will be
used once more in the next patch.

Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20220607104946.18710-34-jslaby@suse.cz


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a7e50de4
Loading
Loading
Loading
Loading
+23 −15
Original line number Diff line number Diff line
@@ -530,13 +530,11 @@ con_insert_unipair(struct uni_pagedict *p, u_short unicode, u_short fontpos)
	return 0;
}

/* Caller must hold the lock */
static int con_do_clear_unimap(struct vc_data *vc)
static int con_allocate_new(struct vc_data *vc)
{
	struct uni_pagedict *old = *vc->vc_uni_pagedir_loc;
	struct uni_pagedict *new, *old = *vc->vc_uni_pagedir_loc;

	if (!old || old->refcount > 1) {
		struct uni_pagedict *new = kzalloc(sizeof(*new), GFP_KERNEL);
	new = kzalloc(sizeof(*new), GFP_KERNEL);
	if (!new)
		return -ENOMEM;

@@ -545,12 +543,22 @@ static int con_do_clear_unimap(struct vc_data *vc)

	if (old)
		old->refcount--;
	} else {

	return 0;
}

/* Caller must hold the lock */
static int con_do_clear_unimap(struct vc_data *vc)
{
	struct uni_pagedict *old = *vc->vc_uni_pagedir_loc;

	if (!old || old->refcount > 1)
		return con_allocate_new(vc);

	if (old == dflt)
		dflt = NULL;
	old->sum = 0;
	con_release_unimap(old);
	}

	return 0;
}