Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2142797iof; Tue, 7 Jun 2022 21:10:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrLoKxhVba4+mb0eWVmQl6EQB/MrvbD00TrWd6QyXVu8zlog3qvwfYMq3jkCRSgV/hzF56 X-Received: by 2002:a17:902:e0c2:b0:167:6128:e63d with SMTP id e2-20020a170902e0c200b001676128e63dmr20629974pla.16.1654661443445; Tue, 07 Jun 2022 21:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661443; cv=none; d=google.com; s=arc-20160816; b=LtMT431/EjTMyniK6zOfE9bMIhcdWqBLXuNUiGIQohp307GMeHPS5mKM68K/gDmIdO RWniByauc9pZluzkxODoG2H093NFJpB3D9QOZkp9pzmurDQ5Cm/R5x9BmqEI7q1WZGdY rB4gtPY2VJAZ6Ccy4p2Axys0uZmMalhAPo4qtIFk8Hhp1+YBcNqgKUkHh3SP1fCWI2m4 KNSiRHGWrzsFLALggj2Kgwc3PvSiQ6XV9OvOA4eZT32c4pr9rrdDjUfePFHHEYs9OGV+ gQswBxX+rtT1Zyaydi8kpFsg9Jj2idVWJg/O3dK8tBe+eK1inli0rG6zwcX+bXwexsWq UGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=AXypnZ6WiOHqzvp/v6LGuwBn5wjho0Mmkh86mIUkjHw=; b=z6axCX0KBVskRpylH34bXvhqCk8kORu94ZUQbRAnuc97LUXMijEcHAlbA4qXy6He+V x7kLE0Tx4kOHxowui6LcT8e89VN8ECohCaek3cKrrReL1DkGJh0TGEHP/Ac2TKbgwsWB dZo6S62iQZLcN5Vo1NeGahMWCmvkP/9zh4mYwQksToCuJiDztGGhYfvGBAP+Am31V0bk /pyPrOhcnZx+Diugrl+c8goRLMC5jkxR0TgUcCt+OrI3/eNP/5/0tmXslQpfq4bfTFax l1q30tBoYrROg/ZLP2IHHnXlCKTizitblBd0gyKVD4VCDWbRPDOhOQSYlbhKXkLASYKC WGiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=iymZZzRT; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h6-20020a654806000000b003aaa7c6cf64si27415294pgs.216.2022.06.07.21.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:10:43 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=iymZZzRT; dkim=neutral (no key) header.i=@suse.cz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D21AE2789AF; Tue, 7 Jun 2022 20:42:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242209AbiFGKxS (ORCPT + 99 others); Tue, 7 Jun 2022 06:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242355AbiFGKuN (ORCPT ); Tue, 7 Jun 2022 06:50:13 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C6BA98082; Tue, 7 Jun 2022 03:49:58 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8DE4321B90; Tue, 7 Jun 2022 10:49:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654598996; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AXypnZ6WiOHqzvp/v6LGuwBn5wjho0Mmkh86mIUkjHw=; b=iymZZzRT6ektOXS6WmPFqBb2sWExFC9jHmUcqZRXg9dlHyNEemUrI317Fyu9VdrV/BgJsB 2RCEmenLDX7I7PVaXM88T45QeTQohw330Du92NZ31lHtMp/hv8acoATYCP7oLDjfd1RSd6 HGSWULbzEDacRZpteIWHai/rUpgcx/I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654598996; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AXypnZ6WiOHqzvp/v6LGuwBn5wjho0Mmkh86mIUkjHw=; b=ZwpZvrTWbfmaG8uoQTsM4on+nmTg+UJVYBHEJ7DTnsOhJSkzh358FJSJSUtrDFLukLDj9G gzNwyWLyyDD/XkBA== Received: from localhost.localdomain (unknown [10.100.201.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 65C092C141; Tue, 7 Jun 2022 10:49:56 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 34/36] tty/vt: consolemap: extract con_allocate_new() from con_do_clear_unimap() Date: Tue, 7 Jun 2022 12:49:44 +0200 Message-Id: <20220607104946.18710-34-jslaby@suse.cz> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607104946.18710-1-jslaby@suse.cz> References: <20220607104946.18710-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Jiri Slaby --- drivers/tty/vt/consolemap.c | 38 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 4d8efe74315c..14d3fbff015c 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -530,27 +530,35 @@ con_insert_unipair(struct uni_pagedict *p, u_short unicode, u_short fontpos) return 0; } +static int con_allocate_new(struct vc_data *vc) +{ + struct uni_pagedict *new, *old = *vc->vc_uni_pagedir_loc; + + new = kzalloc(sizeof(*new), GFP_KERNEL); + if (!new) + return -ENOMEM; + + new->refcount = 1; + *vc->vc_uni_pagedir_loc = new; + + if (old) + old->refcount--; + + 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) { - struct uni_pagedict *new = kzalloc(sizeof(*new), GFP_KERNEL); - if (!new) - return -ENOMEM; - - new->refcount = 1; - *vc->vc_uni_pagedir_loc = new; + if (!old || old->refcount > 1) + return con_allocate_new(vc); - if (old) - old->refcount--; - } else { - if (old == dflt) - dflt = NULL; - old->sum = 0; - con_release_unimap(old); - } + if (old == dflt) + dflt = NULL; + old->sum = 0; + con_release_unimap(old); return 0; } -- 2.36.1