From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 72F0D2DEA6F; Fri, 9 Jan 2026 11:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767959967; cv=none; b=TxqtV2LgFoBkcQSDgr3xHgdKw5iMTIWKafvbpggkMl/yv80ctGiP/0ZgFi2HDrViN45TczipUgTrc8XvDg2lu0GkZhqheoCpl/ryNK/5IPUmkswDyI13py42qUrqr+Mp58muq9BcEek0Tz+nbwzQrSgcVGLCuz0ZdG8v/gyNU/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767959967; c=relaxed/simple; bh=lefDbjO632IEzbVcLyqHgDPjOUuHXOQrPpEUVFeQzJQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XSr/m+WR0oX5n3aCoifk2TcttEG1/6ggN1W62iL9UocQD3G5uy3e+SLScX/ztfI6wnJOn917J4f2YHpbM/tCweQUYYlIzAf6+rDNppIqlMYbGPHbiE2ldx77rjSimOLPoHJC3rHn5/DDk0cgNTZocjSbP3YQYAOLDrOgJJ0JBNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TrLSr1Qg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TrLSr1Qg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02623C4CEF1; Fri, 9 Jan 2026 11:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767959967; bh=lefDbjO632IEzbVcLyqHgDPjOUuHXOQrPpEUVFeQzJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TrLSr1Qgilq7mAu5pF6QlooXAPdcDkDX07dmB+wpPeGK2MPVGkY357Sua5O4Vp+eP 7dC7eMHADjeIMm0DlFBFq0X84UWB/HyhAhoRdnD/V0a8zfNiK+n4gQnJ7kCMyqczwy G6B3T/1SYmqtGOGwHRDQR75Xe4gMwX85nm3lds1I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andy Shevchenko , Rasmus Villemoes , Andrew Morton , Sasha Levin Subject: [PATCH 6.6 238/737] resource: introduce is_type_match() helper and use it Date: Fri, 9 Jan 2026 12:36:17 +0100 Message-ID: <20260109112142.951153270@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Shevchenko [ Upstream commit ba1eccc114ffc62c4495a5e15659190fa2c42308 ] There are already a couple of places where we may replace a few lines of code by calling a helper, which increases readability while deduplicating the code. Introduce is_type_match() helper and use it. Link: https://lkml.kernel.org/r/20240925154355.1170859-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko Cc: Rasmus Villemoes Signed-off-by: Andrew Morton Stable-dep-of: 6fb3acdebf65 ("Reinstate "resource: avoid unnecessary lookups in find_next_iomem_res()"") Signed-off-by: Sasha Levin --- kernel/resource.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index dcc3b564c0537..67410132b40e1 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -310,6 +310,11 @@ int release_resource(struct resource *old) EXPORT_SYMBOL(release_resource); +static bool is_type_match(struct resource *p, unsigned long flags, unsigned long desc) +{ + return (p->flags & flags) == flags && (desc == IORES_DESC_NONE || desc == p->desc); +} + /** * find_next_iomem_res - Finds the lowest iomem resource that covers part of * [@start..@end]. @@ -352,13 +357,9 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end, if (p->end < start) continue; - if ((p->flags & flags) != flags) - continue; - if ((desc != IORES_DESC_NONE) && (desc != p->desc)) - continue; - /* Found a match, break */ - break; + if (is_type_match(p, flags, desc)) + break; } if (p) { @@ -501,7 +502,7 @@ static int __region_intersects(struct resource *parent, resource_size_t start, int type = 0; int other = 0; struct resource *p, *dp; struct resource res, o; - bool is_type, covered; + bool covered; res.start = start; res.end = start + size - 1; @@ -509,9 +510,7 @@ static int __region_intersects(struct resource *parent, resource_size_t start, for (p = parent->child; p ; p = p->sibling) { if (!resource_intersection(p, &res, &o)) continue; - is_type = (p->flags & flags) == flags && - (desc == IORES_DESC_NONE || desc == p->desc); - if (is_type) { + if (is_type_match(p, flags, desc)) { type++; continue; } @@ -531,9 +530,7 @@ static int __region_intersects(struct resource *parent, resource_size_t start, for_each_resource(p, dp, false) { if (!resource_overlaps(dp, &res)) continue; - is_type = (dp->flags & flags) == flags && - (desc == IORES_DESC_NONE || desc == dp->desc); - if (is_type) { + if (is_type_match(dp, flags, desc)) { type++; /* * Range from 'o.start' to 'dp->start' -- 2.51.0