From patchwork Wed Jul 24 06:01:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 814130 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2617816wro; Tue, 23 Jul 2024 23:04:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXw9f1Bg4scXjpIz62gHjoZbm6bj2RKs4gsE5aYEAH5Qmy8ZO5J/IlQoAQ7yGGOq6yGvWu6ZNRQ6w+kuFky5dMr X-Google-Smtp-Source: AGHT+IGccOJ/cOi+LiiQSaQPIJKfeQLUrsh75YFYbqhXxmOKrwq5lt9oKOOphNHcZ2pFiyMRMHmX X-Received: by 2002:a5d:46c1:0:b0:368:7e54:baaa with SMTP id ffacd0b85a97d-369f09ab77dmr1410188f8f.4.1721801077019; Tue, 23 Jul 2024 23:04:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721801077; cv=none; d=google.com; s=arc-20160816; b=SebvKCEIF16epriL9XFkgmEY7od/VadFdUQvAMIEK0zhbxxfJphcfbyR3cMViYRT98 HRFsPKz03uL3gV5nRgtn5We5M2fcr56yvzb+00U8ReQ0zgXWbpKiNscclXZjI4L8GD7Z Ta94rSLPt8XUJ6BDpZN+/fnRiR5MG+3oID1JSmfGtyzs2wFiLcH5QdZ0NkzkuPb44kTV rw48MpvA4AcRQX0v5C8nb5gEqpWv359Iqr+rQNQmWFb/ypnLIEZqJYX6r0ocbZU629ps DXoPiSfYYOb8FB0tSrqnFvOJfSJrOjeI6fP+Gjf5gwfLkPRGsB8LI6j7R3lO22kzvF3H mtLw== 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=XGcJ+qfKtqbk3ZNbYf45k64eJKcZ0PTH5z3ng8es8wE=; fh=eimiGswTlodK8yi2DcDfSicmKwvq5bxKQKpD+SkkTNY=; b=NkJND0AcNRrDhzYKpnsGNLjw0qQlE9T1G8mfI9crISmOZgC6tdkwu8S0CeOgJxSOws DO5c2/3x4kX8VFqgZrPGogDUzUY+/5xD1Oz3u2reSO2wb0g5nANMpKqAQiiqo15M4bMb fEqbZA0jR0X1y7hG0ZrbE1dZoacMPse5WLl5sXNq1dfruHke6IBdJHPv8otx1nzU0gUV HkX2r2X4F/1fnhLVXUZC56V5SO4Z/opPIE/KX6670WjOO61kJBhyEIjvlbG/ZN1nIqbj bpPmVWsvEqkxn3/CVdqke36pBhjNryilGqrdcbVSdWml04dz8IY5wiRCwL5bsCz4unwO P9GQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id ffacd0b85a97d-369e381a792si1327868f8f.642.2024.07.23.23.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:04:36 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 188E0888A4; Wed, 24 Jul 2024 08:03:22 +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 0147D888A2; Wed, 24 Jul 2024 08:03:20 +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 8535D88805 for ; Wed, 24 Jul 2024 08:03:14 +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 4F5D0106F; Tue, 23 Jul 2024 23:03:39 -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 3BA263F766; Tue, 23 Jul 2024 23:03:08 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Marek Vasut , Mark Kettenis , Michal Simek , Patrick DELAUNAY , Patrice CHOTARD , Huan Wang , Angelo Dureghello , Daniel Schwierzeck , Thomas Chou , Rick Chen , Max Filippov , Sughosh Ganu Subject: [PATCH 06/40] alist: add a couple of helper functions Date: Wed, 24 Jul 2024 11:31:50 +0530 Message-Id: <20240724060224.3071065-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724060224.3071065-1-sughosh.ganu@linaro.org> References: <20240724060224.3071065-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 rfc: None include/alist.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/alist.h b/include/alist.h index 6cc3161dcd..06ae137102 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 *