From patchwork Sun Dec 8 00:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 848267 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1467655wrt; Sat, 7 Dec 2024 16:22:03 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWV5KVVL8zYxDSlawjkyS1oWSvGI9n/jPv25WW2es7/2CBKqTWKYmdpq9QzyDYkKzuM1/FwCg==@linaro.org X-Google-Smtp-Source: AGHT+IGAAdRqxbbgczIxa6pgUjwlbRrfcV+ZuYOwosETrZg+FOsbMW4NXRV+fW8U7sYN/baBJU/m X-Received: by 2002:a05:6402:3582:b0:5d0:c801:560 with SMTP id 4fb4d7f45d1cf-5d3be6a1082mr8753017a12.20.1733617323516; Sat, 07 Dec 2024 16:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733617323; cv=none; d=google.com; s=arc-20240605; b=Jc0lyGxLnJRiMRDuJCuCf6ns746DP0jkOmcNZ300q/fd9A4Tgqk6gDDqtmevd+4+FY 4o+CnPu0wnFhdpl6NiFPzIvrgxrCHYo8/I5jjySu/u8DjC8rt/vKdrXd9ANrlm+CudWb WIG2Y4Wi442TdfQiLQDYz1Vt+RPZErW00ToSq0ZKv+irYP3Q5QlI61XO2OYpMWEX9XxO OB5FtA5S1mU/G0iZ04vuK/g2Q585jF0Iiul02ZyjIp3Rk5lbrxsroZlQESAJFcAoqEOw oA0F5LpL//U9yfREygkW64FHrvzgGrO4M5DiX1k/nJ4hFWaVE+ohpk3V3Adz7OB+ugCL zuFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PNCKdtlKp7cJx6A6+2qRAeYNVZFHRjlYGRD8OJC8KOQ=; fh=u094L6RN/tmoEoENJdI3bLC47AnqclF+CCAMtUNu31Y=; b=GH89J7MaE7plocb7To2HYR4hvuB4jZTyYott5yol1SGqa/Au37eP+d6ykJsDSlSnHs 7WTWTzEWDW0mBbvZZPoAiFd3qUv9GT3B08kZ5NxXXYDYHl0oNwfY3hZA9hcVJoO2sQKH KaqCskzDx/q77ZRv5jdAy9nXOSUP8RiBlEO5vVIocc1kd0Tdzpm5HjQomLzTp2ZyFAoS w75jK7ecI4k6qpTlVbYo503Dz83qQ2SV10N8F2TzbxEUxRdyYmiVAkTr6jdJYQ22eI/X qyavwfaXqFm0GNoc0qdA3N3lC7EImrWZEiPKEjaOwZ5llGN2FbRRo2VmviuVIfXnarst AFFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R59f8x1U; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5d3d13bb497si2425806a12.375.2024.12.07.16.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2024 16:22:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R59f8x1U; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36CCB894B8; Sun, 8 Dec 2024 01:21:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="R59f8x1U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9773E8947A; Sun, 8 Dec 2024 01:21:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5C2A4893D1 for ; Sun, 8 Dec 2024 01:21:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-71de02b24cfso268328a34.1 for ; Sat, 07 Dec 2024 16:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733617288; x=1734222088; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PNCKdtlKp7cJx6A6+2qRAeYNVZFHRjlYGRD8OJC8KOQ=; b=R59f8x1UANRQCCCTYxFLALdf9q+pKFNCcBwMUl1JB4x2r0iDW67pw93XdfVm9P611E eQlaZOc7+fzltsbHmKdk+Pti0wNgt0DgFROUs3U7MDWQUllib3MB/j+4imObfQpH5USj TxqYp/1zj0qJbNESBYawowrT7+7yXw25eVDpO1eFqxTAKNYJ6+DbnOBrl4ZPssxwDTxz /wJo/t51thcINWBVhFklEzggTfm0NHCWe+2td+6kpjq2nUuD1jzw/8ypP0QmJJAgS+rz CeeFFRmFEFtuVqsjV37XvTFKzWl5am47FWKFRxALkh+ZsvjNaqrSoeYult9I3mOrldRZ icjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733617288; x=1734222088; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PNCKdtlKp7cJx6A6+2qRAeYNVZFHRjlYGRD8OJC8KOQ=; b=Z3gtVxrtGhWeDuS2AFcSIhN717P+/7wr3uMm4Tp70sWZ36deANDwCI6uTl6uFqqMay itKbAC2T+FRCjqjUXtAoDT3hKox8gQ9KNANiMHWkLBxAs+Vwl8KGW3H7oIED0/iatYYT ufFksLduG3SakBjLgxLZTrQtIlUl8cvgn+2GZzIsQias/5LTsh6l1NkYI51MewxBM3bO GcuhFqZuQUJdZAPtHC2kRvs2oqL2vDdumCHg8rA6ppqAaJLEcjYqn+w/L2M8WLKFxRd4 e5IHXQEd4gjJvM99ay2pde7lG8jG4YJe1RIsEOfqDdzhpXxt6MMpU2Eun6OFto+J01OO GuEA== X-Forwarded-Encrypted: i=1; AJvYcCVaMIo6krC08ZPqrcsGiZV9eZDc1+5rEdsmRvWPZ0q9CUFhiTGcAx3VDxed2CVFtFiPeXo7D7A=@lists.denx.de X-Gm-Message-State: AOJu0YygqbbjqpTdijy9fr9AJWRl7OIjV3fo1n+ZZO7E+Ud3OGNJ6DMq Mnq2Np6morftNF6/Pm1HtEEeH862vhvfKqK3FnlRjQp5uDpMF/GNXnHLYW5ObVU= X-Gm-Gg: ASbGncvLtnVURd2K8jlo93ZLmyG3c6fJKfBXgzluazVE0ZgWwX2Nm5DpuwXu2X+dY8h CbqaozihfFxSN7QKyZOnLHLchhBaJHVHzBEuW2aV8xikVt0rzYcz27xgYaIYRVGaZQT+QxxtkZA uigQaLIlyiHBhlOUcZPN/x87YavK2OSbvi2DjlZ9BibyPY880oNZ1U5Vh/CslXv5jBEsKNQDs8w kZSPQPdiVGW8hZPloqkTHzt/mcpsefhCQ+mTkcfEssPFbBV38oCxbo= X-Received: by 2002:a05:6870:d86:b0:29e:290f:7af4 with SMTP id 586e51a60fabf-29f73860dcemr3991998fac.34.1733617288252; Sat, 07 Dec 2024 16:21:28 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29f7e411dafsm1161519fac.36.2024.12.07.16.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2024 16:21:27 -0800 (PST) From: Sam Protsenko To: Tom Rini Cc: Ilias Apalodimas , Sughosh Ganu , Heinrich Schuchardt , Simon Glass , Caleb Connolly , Marek Vasut , Laurent Pinchart , Patrick Delaunay , u-boot@lists.denx.de Subject: [PATCH 4/6] lmb: Improve coding style Date: Sat, 7 Dec 2024 18:21:19 -0600 Message-Id: <20241208002121.31887-5-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241208002121.31887-1-semen.protsenko@linaro.org> References: <20241208002121.31887-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Fix checkpatch warnings. No functional change. Signed-off-by: Sam Protsenko Acked-by: Ilias Apalodimas --- lib/lmb.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 1642ce48bbbd..8c1c9b0f67c8 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -57,7 +57,6 @@ static long lmb_regions_overlap(struct alist *lmb_rgn_lst, unsigned long r1, unsigned long r2) { struct lmb_region *rgn = lmb_rgn_lst->data; - phys_addr_t base1 = rgn[r1].base; phys_size_t size1 = rgn[r1].size; phys_addr_t base2 = rgn[r2].base; @@ -70,11 +69,11 @@ static long lmb_regions_adjacent(struct alist *lmb_rgn_lst, unsigned long r1, unsigned long r2) { struct lmb_region *rgn = lmb_rgn_lst->data; - phys_addr_t base1 = rgn[r1].base; phys_size_t size1 = rgn[r1].size; phys_addr_t base2 = rgn[r2].base; phys_size_t size2 = rgn[r2].size; + return lmb_addrs_adjacent(base1, size1, base2, size2); } @@ -235,9 +234,9 @@ static long lmb_add_region_flags(struct alist *lmb_rgn_lst, phys_addr_t base, coalesced++; break; - } else { - return -1; } + + return -1; } } @@ -288,14 +287,17 @@ static long _lmb_free(struct alist *lmb_rgn_lst, phys_addr_t base, phys_addr_t end = base + size - 1; int i; - rgnbegin = rgnend = 0; /* supress gcc warnings */ + /* Suppress GCC warnings */ + rgnbegin = 0; + rgnend = 0; + rgn = lmb_rgn_lst->data; /* Find the region where (base, size) belongs to */ for (i = 0; i < lmb_rgn_lst->count; i++) { rgnbegin = rgn[i].base; rgnend = rgnbegin + rgn[i].size - 1; - if ((rgnbegin <= base) && (end <= rgnend)) + if (rgnbegin <= base && end <= rgnend) break; } @@ -304,7 +306,7 @@ static long _lmb_free(struct alist *lmb_rgn_lst, phys_addr_t base, return -1; /* Check to see if we are removing entire region */ - if ((rgnbegin == base) && (rgnend == end)) { + if (rgnbegin == base && rgnend == end) { lmb_remove_region(lmb_rgn_lst, i); return 0; } @@ -340,6 +342,7 @@ static long lmb_overlaps_region(struct alist *lmb_rgn_lst, phys_addr_t base, for (i = 0; i < lmb_rgn_lst->count; i++) { phys_addr_t rgnbase = rgn[i].base; phys_size_t rgnsize = rgn[i].size; + if (lmb_addrs_overlap(base, size, rgnbase, rgnsize)) break; } @@ -715,7 +718,7 @@ long lmb_reserve(phys_addr_t base, phys_size_t size) } static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, - phys_addr_t max_addr, enum lmb_flags flags) + phys_addr_t max_addr, enum lmb_flags flags) { int ret; long i, rgn; @@ -730,16 +733,18 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, if (lmbsize < size) continue; - if (max_addr == LMB_ALLOC_ANYWHERE) + + if (max_addr == LMB_ALLOC_ANYWHERE) { base = lmb_align_down(lmbbase + lmbsize - size, align); - else if (lmbbase < max_addr) { + } else if (lmbbase < max_addr) { base = lmbbase + lmbsize; if (base < lmbbase) base = -1; base = min(base, max_addr); base = lmb_align_down(base - size, align); - } else + } else { continue; + } while (base && lmbbase <= base) { rgn = lmb_overlaps_region(&lmb.used_mem, base, size); @@ -813,7 +818,7 @@ phys_addr_t lmb_alloc_base_flags(phys_size_t size, ulong align, } static phys_addr_t _lmb_alloc_addr(phys_addr_t base, phys_size_t size, - enum lmb_flags flags) + enum lmb_flags flags) { long rgn; struct lmb_region *lmb_memory = lmb.free_mem.data;