From patchwork Mon Aug 17 16:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 11718803 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6079613A4 for ; Mon, 17 Aug 2020 16:37:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4414D205CB for ; Mon, 17 Aug 2020 16:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731265AbgHQQhK (ORCPT ); Mon, 17 Aug 2020 12:37:10 -0400 Received: from mga11.intel.com ([192.55.52.93]:33118 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388839AbgHQQhH (ORCPT ); Mon, 17 Aug 2020 12:37:07 -0400 IronPort-SDR: 0eKDBNoZ7BfRANjZo8F7bYwS4Ad9HpkK12anzrHgSG+8fDaYYyU1Odx4Z9V3ZGG7QARIr5hHwq 0hfyPBSSa4ug== X-IronPort-AV: E=McAfee;i="6000,8403,9716"; a="152384829" X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="152384829" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2020 09:36:50 -0700 IronPort-SDR: WQf+SFP6npg57i1QN9mJlgL5P4IEAPgvvuWqydHSynS2YBw4ets0Yo9n565VM/JWJfAQ/fpGft uwLZFcL+klAg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,324,1592895600"; d="scan'208";a="310147394" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 17 Aug 2020 09:36:48 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C697211E; Mon, 17 Aug 2020 19:36:47 +0300 (EEST) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v2 2/8] resource: Simplify region_intersects() by reducing conditionals Date: Mon, 17 Aug 2020 19:36:41 +0300 Message-Id: <20200817163647.48982-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> References: <20200817163647.48982-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Now we have for 'other' and 'type' variables other type return 0 0 REGION_DISJOINT 0 x REGION_INTERSECTS x 0 REGION_DISJOINT x x REGION_MIXED Obviously it's easier to check 'type' for 0 first instead of currently checked 'other'. Signed-off-by: Andy Shevchenko --- v2: converted ternary to usual if-cond (Rafael) kernel/resource.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 841737bbda9e..be134bd5d82e 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -554,13 +554,13 @@ int region_intersects(resource_size_t start, size_t size, unsigned long flags, } read_unlock(&resource_lock); - if (other == 0) - return type ? REGION_INTERSECTS : REGION_DISJOINT; + if (type == 0) + return REGION_DISJOINT; - if (type) - return REGION_MIXED; + if (other == 0) + return REGION_INTERSECTS; - return REGION_DISJOINT; + return REGION_MIXED; } EXPORT_SYMBOL_GPL(region_intersects);