Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1372442lqh; Mon, 6 May 2024 06:04:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5hgyeVS9WpmesjYGxEHiRcgear3FsCYtd7GUjdgSbrOWqsn72Y7sjNz/g0oKfbFpPcpnrCwgw2UfwmW7011RM9FEL/oAHpxwjOvAYMQ== X-Google-Smtp-Source: AGHT+IFQuJfmY0k1K+xY+op4R1WTLcGEMO8bquGUSEHWbe2RoT39DQcjjMc+nKhBQY+jkEfY5TJF X-Received: by 2002:a17:906:57c8:b0:a59:a0f7:7dda with SMTP id u8-20020a17090657c800b00a59a0f77ddamr4818248ejr.4.1715000654421; Mon, 06 May 2024 06:04:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715000654; cv=pass; d=google.com; s=arc-20160816; b=UVgOH1edN1JpuJcmd2L6EqNDVsUR7ySgW6IPi/bSh4UpYNg2aiYsXSnP6UIoQBYK3c 2EVQHb++NIXoDGmjnKnULBrd3Op7R0gF2XikPTf+kue4T53v0CqrwhBkZ4ZhJKjuoO6J o768ZBlqrqxghTSc+TdJk0ngz+Lo9+F0CjP16X0lDN6xQFiqfSRHgWkUkMscLlnlH8B0 aLUkzP8lrdspJManyp48WoXC36IZ2jmpxsY65Q8OLDFmM2M669VYPxIPthDPeQCagsAo FRhwRmqDSbV4DHqxitZ/59HsoYRW3zu4xDeQdNizbweLfY9Na26abX9Gkuc19e1Cgq3l AUbA== 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=/MDypSlBSJ41vkxKcoU8OFABxWRcuarFzIFy+RbkIT0=; fh=iQIEIpegfxGHAXzmCmQbfua7u3pb28YTuJpmY/Z0V14=; b=wGozem4cQdrlLeLiH/fdzPOURF8nNqpddt4uEndT3xhRctJjN6lRAdyjnclwQ2PfsJ uJVMJybRDoudY49nDZ05IE6zRbbnFtrm0WCmS2IG9kU1sHH+bGkNpp+LCfcABXBd7TWn pnLmDo0ENq1zK+3yjotDb191OnvF2QJtqQNF1uOdugbnzK+deWoMt3LBqpOjV7sAdMMW Zwzsh/Uoa6sOyw/RaCDTt4jxhJ6F5A/T+UDR9hZUljjbK4YOoCfz5hMqrbDsGQWrRjYj tYnPcsALf0s+Il3cNsSJ2qRlLYdrCZjO/RaK5jEmFytd/DbwAZkFSTOJ/m1r2anesZ4C mSTQ==; 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-169865-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169865-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hs12-20020a1709073e8c00b00a59a7ae04f1si2892364ejc.725.2024.05.06.06.04.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:04:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169865-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-169865-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169865-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2AF6A1F24A7D for ; Mon, 6 May 2024 13:04:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C6747B3E1; Mon, 6 May 2024 13:03:19 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 CCE6378C60 for ; Mon, 6 May 2024 13:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; cv=none; b=Uxf53VKgkFbx9qyqXpEOyd8R7f2NbprJ5PeC4sPyeHygCloZTZc4AVIStSKEXttvpBZGt5ipk4HpWcXsd7S3otS/bH+bbb5gmIwJ+rVSqkcLOimcmTBQhIbFV/y+4zNbFB+hNt/JnojR4aM10/1T9GPn2o+QkTNJNvYLNl12y6U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; c=relaxed/simple; bh=+ulLU4slP0ZpFDa6qvL8fvK6SU8hdStisvDrncOSz4Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JetqGsM3gPCC+ThQotl/PCiddmpchN105ZmK/YN9oxR1HR1G6wYNBzsBwHIA+iUj1v1vVHy0VYjkg7CZtIMvnBJy2Y28xnAE9cIVXH+9CUokiG62UEVGm6BBSz3Fg9kLmlviTXVqy5lSvWs1cGycKp8Hssh87+beq6yGb2jU0eQ= 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.188 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.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VY1hF6TMTzcp0d for ; Mon, 6 May 2024 20:59:25 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id B6F59180065 for ; Mon, 6 May 2024 21:03:13 +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:13 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 5/5] genirq/irqdomain: Clean up for irq_domain_xlate_* Date: Mon, 6 May 2024 21:02:23 +0800 Message-ID: <20240506130223.317265-6-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) As irq_domain_xlate_onecell() and irq_domain_xlate_onetwocell() have almost the same logic, introduce irq_domain_xlate_common() to do it and use a new xlate_type enum variable to distinguish them. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 2ef53697d877..4dd53d76f7ef 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -985,6 +985,29 @@ struct irq_desc *__irq_resolve_mapping(struct irq_domain *domain, } EXPORT_SYMBOL_GPL(__irq_resolve_mapping); +enum xlate_type { + ONE_CELL = 0, + ONE_TWO_CELL, +}; + +static inline int irq_domain_xlate_common(const u32 *intspec, + unsigned int intsize, + unsigned long *out_hwirq, + unsigned int *out_type, + enum xlate_type type) +{ + if (WARN_ON(intsize < 1)) + return -EINVAL; + + *out_hwirq = intspec[0]; + *out_type = IRQ_TYPE_NONE; + + if (type == ONE_TWO_CELL && intsize > 1) + *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; + + return 0; +} + /** * irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings * @@ -995,11 +1018,8 @@ int irq_domain_xlate_onecell(struct irq_domain *d, struct device_node *ctrlr, const u32 *intspec, unsigned int intsize, unsigned long *out_hwirq, unsigned int *out_type) { - if (WARN_ON(intsize < 1)) - return -EINVAL; - *out_hwirq = intspec[0]; - *out_type = IRQ_TYPE_NONE; - return 0; + return irq_domain_xlate_common(intspec, intsize, out_hwirq, + out_type, ONE_CELL); } EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell); @@ -1037,14 +1057,8 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, const u32 *intspec, unsigned int intsize, unsigned long *out_hwirq, unsigned int *out_type) { - if (WARN_ON(intsize < 1)) - return -EINVAL; - *out_hwirq = intspec[0]; - if (intsize > 1) - *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; - else - *out_type = IRQ_TYPE_NONE; - return 0; + return irq_domain_xlate_common(intspec, intsize, out_hwirq, + out_type, ONE_TWO_CELL); } EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell); -- 2.34.1