From patchwork Thu Aug 13 17:57:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 251755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CB5CC433DF for ; Thu, 13 Aug 2020 17:57:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6967520829 for ; Thu, 13 Aug 2020 17:57:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726522AbgHMR5j (ORCPT ); Thu, 13 Aug 2020 13:57:39 -0400 Received: from mga01.intel.com ([192.55.52.88]:59185 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726174AbgHMR5h (ORCPT ); Thu, 13 Aug 2020 13:57:37 -0400 IronPort-SDR: UkzOc6y4E1e8l5s2gQYx8odCpcP50qwtNHvGEkD3iaa6Jva7VmQGYaQf0okeR7dq3UBWdlzWtX Gyy4Uy8omxbA== X-IronPort-AV: E=McAfee;i="6000,8403,9712"; a="172337144" X-IronPort-AV: E=Sophos;i="5.76,309,1592895600"; d="scan'208";a="172337144" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2020 10:57:33 -0700 IronPort-SDR: 2uxO2NsFaBBl8UnqRQ3frtd2J8wYnbcBIczkZXRbjyHLznc7M/vxd4Snc6Lnzd1s4ccsKmhLsa aMbgVL9Qfb7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,309,1592895600"; d="scan'208";a="278195282" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 13 Aug 2020 10:57:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 49CF2190; Thu, 13 Aug 2020 20:57:30 +0300 (EEST) From: Andy Shevchenko To: "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v1 1/7] resource: Simplify region_intersects() by reducing conditionals Date: Thu, 13 Aug 2020 20:57:23 +0300 Message-Id: <20200813175729.15088-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.28.0 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 --- kernel/resource.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 841737bbda9e..70575a61bf20 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -554,13 +554,10 @@ 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; - - return REGION_DISJOINT; + return (other == 0) ? REGION_INTERSECTS : REGION_MIXED; } EXPORT_SYMBOL_GPL(region_intersects);