Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp476361lqb; Wed, 17 Apr 2024 01:53:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeATFwHG95ciaqhWmw3SdHy9KDg9AGIfyRKjBxvvb+bmQlvrTHw3whzijYBL9hNrB/vMJZlv5y2hxhg1fuPTEfJOBwp+MYfprfhy0D9Q== X-Google-Smtp-Source: AGHT+IE1rZSVFDTSrvII8byd1Uu0EfdpsJwHuIH81DmsFeR/S80z2GXlO6l68sMihInbibBVGiWs X-Received: by 2002:a50:cd98:0:b0:56e:3293:3777 with SMTP id p24-20020a50cd98000000b0056e32933777mr12770227edi.17.1713344036366; Wed, 17 Apr 2024 01:53:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713344036; cv=pass; d=google.com; s=arc-20160816; b=myTExlDiQiM9iXrTcexY98jFVVgPXUtoPjexRrg1dnP6AzNaXAn7m89OMAwdA/UQqx wYrGR9ON6Ylzpzr+Z+uUQYRXM3Tqmx5XXCN8w/AwOTUr91jodZl/d4jP55RDBnlpwymo 6GwyGKrsBoRk/mxVNW1+aS3wjmi024+TTPeW7WFESxS7tCB5c/n872iHZeCgheK4OYA6 fTRyzXkHkWwo1mcHxGDDjuL72RuJut/81Jt1CoysA6D8Is7xJObwoaFANjtaQDpK6AK2 JyN+pbyDZPH0e9ZhSFcLS778vnN/W6wW37LawylCYyrB5jGLslbKQ/iumcLjc3WGRRnC +Czw== 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:message-id:date:subject:cc:to :from; bh=8t3D/6q8BA6vcuGrhZV1eh9A5VUyv9hX0GaDlvAsoGo=; fh=iQIEIpegfxGHAXzmCmQbfua7u3pb28YTuJpmY/Z0V14=; b=FoBMShUdBlDXtoQ3zNZYiSrzF10PYhPDyXZEz9lZB9FTh4x5A/AHIpScb08x2FegU5 1w6oz+xJQ5L611UDX2NGz+QX/vzwA75tQk1EXUXDny7KtKyv3P4kBqszVyj2QlswNTc+ aaLuXtjYA3xCor9/FBUqw50B9QM7Q5Xz6Uz3P+3L7VOhYQyWun4D2+Y7ezz/NCMlWDzF qhO6j4FDEAnrfWCsBf50gBC6VK55kF3A3f58Yq4QCCbfiPssMs/4HyCWn0ATtf35U8Se 7DrJfZIFgQbSuyNxEn+u+9rBzAj3QBSrV5QZ7oE7/Jp4IPNxu2V3nRKgkIjuY/nZ3Yud C4Lw==; 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-148175-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148175-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 i23-20020a508717000000b0056e2a157a9bsi6798697edb.552.2024.04.17.01.53.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 01:53:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148175-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-148175-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148175-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 1ADD11F22377 for ; Wed, 17 Apr 2024 08:53:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 570CF128807; Wed, 17 Apr 2024 08:53:50 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (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 0473027701 for ; Wed, 17 Apr 2024 08:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344029; cv=none; b=eRYwT1z5YBIsL7gHvv2BAQaChWeu6Dd7lWUaosAn4rh3yF4SZeojcPcbeWIELOqUO3NaAxqdma2bB9nt+nz4YvS7IzB//hzKuDI1UspEwFjFt0ZmNWmHcKiYD+KcWhj0ET43rm9yFqiDQ8VtJBFhV12IylbTCexDW8YH9zMrxWQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713344029; c=relaxed/simple; bh=Jxp5iGC+oiD4XSKrX3vbfULJ6vMyg2omC5NIy3We4vI=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=uYnPU9QqSMZXOEZcG7JdNDNacsP3ZQ5rXZYKO7s/1rwRRo2qm58AViFXqOaKTS8ItJaJZfnpWF34BgpP776mNzw1g948Z+1dvWweyUwAqo7LZi+3QZN0xLWGFwNZk1np5Nf2Umq39LIRuD2Kz1FrHpnE8zbcHLH/JK41VsFTsaQ= 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.35 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.163]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4VKF454m64z1RCRw for ; Wed, 17 Apr 2024 16:50:45 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id 0315B18001A for ; Wed, 17 Apr 2024 16:53:44 +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; Wed, 17 Apr 2024 16:53:43 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH -next] genirq: Simplify the checks for irq_set_percpu_devid_partition() Date: Wed, 17 Apr 2024 16:53:56 +0800 Message-ID: <20240417085356.3785381-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 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: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500008.china.huawei.com (7.221.188.139) Since whether desc is NULL or desc->percpu_enabled is true, it returns -EINVAL, check them together, and assign desc->percpu_affinity using "?:" to simplify the code. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdesc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c index 23120e5a46a9..6b19c72db29a 100644 --- a/kernel/irq/irqdesc.c +++ b/kernel/irq/irqdesc.c @@ -911,10 +911,7 @@ int irq_set_percpu_devid_partition(unsigned int irq, { struct irq_desc *desc = irq_to_desc(irq); - if (!desc) - return -EINVAL; - - if (desc->percpu_enabled) + if (!desc || desc->percpu_enabled) return -EINVAL; desc->percpu_enabled = kzalloc(sizeof(*desc->percpu_enabled), GFP_KERNEL); @@ -922,10 +919,7 @@ int irq_set_percpu_devid_partition(unsigned int irq, if (!desc->percpu_enabled) return -ENOMEM; - if (affinity) - desc->percpu_affinity = affinity; - else - desc->percpu_affinity = cpu_possible_mask; + desc->percpu_affinity = affinity ? affinity : cpu_possible_mask; irq_set_percpu_devid_flags(irq); return 0; -- 2.34.1