Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1391207lqh; Mon, 6 May 2024 06:32:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxx1Ulepbepf12f5gAdEhQsRyj5tisSN6TFuKl1Jq1/R0n/FyS2/g+6jCMM8MEhLt7cKtUbbNUDN3itJpZeu6GVVSbHGhtYr2MTpZSsQ== X-Google-Smtp-Source: AGHT+IHylv9fpXj8h6SqxXKOEjQTeH1rYkh4vkg7MCstrGpFrbHFepjnc4Ln9zJFizOiKjzo1wV4 X-Received: by 2002:a05:6a00:841:b0:6ed:de30:9e43 with SMTP id q1-20020a056a00084100b006edde309e43mr14262115pfk.32.1715002370497; Mon, 06 May 2024 06:32:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715002370; cv=pass; d=google.com; s=arc-20160816; b=sVuYrMtygGNN80V9U5UfS7dY06VxmtqSyn4bvLK/EB2RE7IhN2HG45yQC+gxpLmEc/ a8NCynGQwbQt40IWNXnx+h8NjNhJZv5iGYwFEbY6WMkNRC8bepNYxx7Nrfs5YQIbveB4 4K3VdOu1zV2KaN6iRausp0hCVvHefnrue60bN86GjDuzSFdsJp/JFAa345AZp2jECbgX IizINyGzKxwwBc0o12BYKsr9lHQ63e7Oya06pbZ9H4SbskOGsC08Dz9+3jn7RnEWu5nf dz+/7v025cCMEsCm7TWzSjOKElog5EviMMWDNarFET5EFeiy49M0b4h8r7CduWUpGBPd vipA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8F9VpnHGDA1Uov0nCbKVxhWnKGQ8eHlbbnHKO+zhxyU=; fh=iQIEIpegfxGHAXzmCmQbfua7u3pb28YTuJpmY/Z0V14=; b=MfXiTUE4cuR5NjzO5eCeOSWx+VjMkQoq0fYm6BPQPtswsWt3S8v6PddvHJaa6rUQVQ PNGxQ3rCjFV6+6avOpz5oE1Tii69G19I5+oUlTiShEB+LC7bn2yk4J9iLHAAgqXQprVi M5dfy2dos8AMzg6aBkBL/NHj6mLh0VCPdMONYT98Rd/ZZl7BtEWDMMl3+OsKevL8U/Kl PwzzISbE2V/frOabOq+M/8eBTg++bhcyrnuhKTKJGpYAQADnlZ7pXVxkYO8G1T4q/e8y j1tJ6KZLnQFQ6OS78rWqCCP2+kjS8uG57VCxRARQklkPCWslqyzAgDdKwgc1syHMtnSd C1Xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-169863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u13-20020a6540cd000000b005dbcf14be2bsi8483937pgp.800.2024.05.06.06.32.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-169863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E719DB26A08 for ; Mon, 6 May 2024 13:03:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 840C978C80; Mon, 6 May 2024 13:03:17 +0000 (UTC) Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10D5E6D1BB for ; Mon, 6 May 2024 13:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000597; cv=none; b=Ev3Fsfd42ht7QkECYBFwjfXst/h6KXag0cS8gEXErD64gDMR5Mtjz3galSpCBG+R22743NanLo4IMfE+yS3P80nvNYgGt/2TezT/D8DpTorSzBXfviXQUa5tTrKkxMN7k/ZXQVfRWSDC5Ll/vLb2O+FiECO9zhrzbXqCQ2Vu3a0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000597; c=relaxed/simple; bh=SWCL/GgvDvSAFp81ExaUX0cbPTexrcab9TT6aTWubmw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X4Oc0TugVfx9rYBTeuCX+q/XVfE39e7UnzzGvar1sYY8aokHI4fyNLz3ONPFiFVgACne7DHfNfqT6ZOBWmNiYxrRfUc4l1v6kXsm0OZBc+NqXgT9M5eL8lBE26ir3gqvs1A+ieNm5gX5MUgI/V+aycTgNmU7dHOD7NzXIbCv1Lw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VY1lH5v0mz1xmgr for ; Mon, 6 May 2024 21:02:03 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id C10761A016C for ; Mon, 6 May 2024 21:03:10 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:10 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 3/5] genirq/irqdomain: Clean code for irq_create_direct_mapping() Date: Mon, 6 May 2024 21:02:21 +0800 Message-ID: <20240506130223.317265-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Add "out" goto label for irq_domain_update_bus_token(), and "out_free_desc" goto label for irq_create_direct_mapping(), which can simplify the code. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 42bdbd04bc3c..6d8a368c677b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -317,10 +317,8 @@ void irq_domain_update_bus_token(struct irq_domain *domain, domain->bus_token = bus_token; name = kasprintf(GFP_KERNEL, "%s-%d", domain->name, bus_token); - if (!name) { - mutex_unlock(&irq_domain_mutex); - return; - } + if (!name) + goto out; debugfs_remove_domain_dir(domain); @@ -332,6 +330,7 @@ void irq_domain_update_bus_token(struct irq_domain *domain, domain->name = name; debugfs_add_domain_dir(domain); +out: mutex_unlock(&irq_domain_mutex); } EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); @@ -672,17 +671,18 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain) if (virq >= domain->hwirq_max) { pr_err("ERROR: no free irqs available below %lu maximum\n", domain->hwirq_max); - irq_free_desc(virq); - return 0; + goto out_free_desc; } pr_debug("create_direct obtained virq %d\n", virq); - if (irq_domain_associate(domain, virq, virq)) { - irq_free_desc(virq); - return 0; - } + if (irq_domain_associate(domain, virq, virq)) + goto out_free_desc; return virq; + +out_free_desc: + irq_free_desc(virq); + return 0; } EXPORT_SYMBOL_GPL(irq_create_direct_mapping); #endif -- 2.34.1