From patchwork Thu Jul 4 07:35:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 809912 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1042160wru; Thu, 4 Jul 2024 00:37:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVvahrO8yaxNodL4siytDRI79ZYn+Z5MSCOckUY3NjIz0J8Mdn95zbfHdN/BkGsj3A9zfNzWXoMU8qWjV7SLTDp X-Google-Smtp-Source: AGHT+IEE1kEANXq4ZCYlI5+dgABKSQzXHCwJoEl/EOA5+VHHCr9UBcLMzLfHoMOqbIAuRN81SrR+ X-Received: by 2002:a05:6402:5cb:b0:58d:727b:1de1 with SMTP id 4fb4d7f45d1cf-58e5cd12733mr593745a12.39.1720078624550; Thu, 04 Jul 2024 00:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720078624; cv=none; d=google.com; s=arc-20160816; b=m39vkjj+oDb7pGKBnS3MPcMOdu98LjocnhpdHUxkFbeRZUgLBGICX0nO+KkXD4UEpR pfxT+NLwNJI9aTrnrlguIPx18W6CsyFJWDvrm8Pud4pN/b1dDlf9HllvIIduIVsAZnPU wr4Y8Z5zZa2XER2Oeh4CD3T5wXPB8xG44jpgbNdOcKYJedYQCyu4k3FbC62T3zEW8ckN 3Ja05hBG1xyX4ez0wLmtAAMVVckqgZhGG7NMaeUvysxHjx2IQMyK+tx3uG/vBjjd33G9 Wtt46HS6FYwoKtAK+aK5iYJqUL2Gq3UhghK7I3sjB7iiqBfalEnZnc38z7bRw4SbBIx2 wvfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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; bh=m22dfi2mix6KDaVyeci+FvFFblV6Hq5GGBgorfvbtc8=; fh=ez1zzjhC0XWyqTp7tWutqrA/nFdALDnQKrnQnXYhk5Q=; b=FPSmoj1yZVFQuq4ylaUQk0Xq3iGYh3SoGhvrGP19fJRh4dJWzpGvix5B5ZdZ1zWLTa qjXhd3htDY6Q0Vb3qirJnZts87UJX0fwPpSIh1f7R2luHIgj4gugWEeFCgTSz+E6vpIG FXPziZsh3pgyOBzvD7tJxZuwqD1a0zUJK4sEPLuDuETvj44iLG3kceUpnk7UwMd9mQiE R2+FXZorQtP9Ak9BU7xNygalIjtX4NbvOL6+kNu1GnojO/qNy3xsLb6cUjE4AxpgLudd zcaVunGy9eTYgekdlGz0IXJz3Zsf60Fwt6o2ROBBH7Ity7e2/6fJxjuiwuY9S291h4mX I2OQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-58c1d157bacsi2066675a12.442.2024.07.04.00.37.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 00:37:04 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DA28888C3; Thu, 4 Jul 2024 09:36:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 3257F888AF; Thu, 4 Jul 2024 09:36:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 098E7888C2 for ; Thu, 4 Jul 2024 09:36:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8B0DA367; Thu, 4 Jul 2024 00:36:47 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 676253F762; Thu, 4 Jul 2024 00:36:19 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Tom Rini , Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Fabio Estevam , Michal Simek , Sughosh Ganu Subject: [RFC PATCH v2 05/48] alist: add a couple of helper functions Date: Thu, 4 Jul 2024 13:05:01 +0530 Message-Id: <20240704073544.670249-6-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240704073544.670249-1-sughosh.ganu@linaro.org> References: <20240704073544.670249-1-sughosh.ganu@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 Add a couple of helper functions to detect an empty and full alist. Signed-off-by: Sughosh Ganu --- Changes since V1: New patch include/alist.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/alist.h b/include/alist.h index a68afc9fff..bab146c35d 100644 --- a/include/alist.h +++ b/include/alist.h @@ -82,6 +82,28 @@ static inline bool alist_err(struct alist *lst) return lst->flags & ALISTF_FAIL; } +/** + * alist_full() - Check if the alist is full + * + * @lst: List to check + * Return: true if full, false otherwise + */ +static inline bool alist_full(struct alist *lst) +{ + return lst->count == lst->alloc; +} + +/** + * alist_empty() - Check if the alist is empty + * + * @lst: List to check + * Return: true if empty, false otherwise + */ +static inline bool alist_empty(struct alist *lst) +{ + return !lst->count && lst->alloc; +} + /** * alist_get_ptr() - Get the value of a pointer *