From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38DF8C4332F for ; Thu, 30 Sep 2021 16:22:25 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8CCFE61139 for ; Thu, 30 Sep 2021 16:22:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8CCFE61139 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 734AD81194; Thu, 30 Sep 2021 18:22:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com 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=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="yo4cZEFi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0CA1381F0C; Thu, 30 Sep 2021 18:21:46 +0200 (CEST) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (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 C3511815A8 for ; Thu, 30 Sep 2021 18:21:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aouledameur@baylibre.com Received: by mail-wm1-x332.google.com with SMTP id s24so5131278wmh.4 for ; Thu, 30 Sep 2021 09:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V0GV8oeVV2Ag6RJSRH36Ver3gjwZq3kQs/93aAQ3kyQ=; b=yo4cZEFikP7ddZuZiY4fYmxJ/f/wkGta2nVxVwts/1cm4Sch8ST2Eos/0bTkBmrrqy a/bSrG8JT3uzvlN+z2xbooaIJdepsRsDki7XZ+Z8usBpDO5G0YU4VhmdUPp+TkTKMtbj mTvciKZEdnOHC36sKPR+D/wrYcU0TzogW8kghecaOXogC/uRxniOYS5KtXhfOM2joLNQ 2keYfThklcEc95fpijeNaUL2fE5F45Kd+ZKMOp+L6Oyy9UBkRzteewI+D/u45hUWy9AQ gqKzut+QgEoMEqYNMLjNfY0gYyTIDapWfTkFj85u6HbJL6NNEK7EoRC7iZszKU1kFclI 02kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V0GV8oeVV2Ag6RJSRH36Ver3gjwZq3kQs/93aAQ3kyQ=; b=Dvg2xxhFBY6+LG97r6iT1OZYKfoFo6WCm9XcCTbxlnEjqfLMmW4NRA5WFhEq32U2HR mtmoDxlWwmWZK9hRgK+g2aDY399SYOBI969RmOMEM/8d8gseSayf0gIxmWS2DQb6RI+Z v01MoLDY2d1W4B57eZ8wVLfYVqIFACgQU6Kd8VlcZJj4jqrZh5hRf6+qtyQAUzipF5RR QptAafAxSqpv1iKNyjK+MjJ1jmDdjJHxhnnMlkynVMwSAqekpLj0YZljwKJic0n+RR0u yt4Tc2I1uFyYVqGkTM/7b5Xvrp68N+vaHLtGT9bsOt8KeZRT6z8tqiwZXZl37Uwm6/2e /J8g== X-Gm-Message-State: AOAM531V9ssAGDZFZGzXMofzA647sQ8i/6cjqOCES1JBAjQm+JSXnFhm /eAEzwqX6LtUx72HrAKhXVfiRUlm7+pePJUX X-Google-Smtp-Source: ABdhPJz/WzQTQo4nre1iWvpZhltz9NiRlK0oRYD90B4R34SXCCip7o1Fh2oOkJ1jb/U33+yR8Op2aw== X-Received: by 2002:a1c:44d6:: with SMTP id r205mr15759wma.174.1633018893421; Thu, 30 Sep 2021 09:21:33 -0700 (PDT) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id s13sm1846393wrv.97.2021.09.30.09.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 09:21:33 -0700 (PDT) From: Amjad Ouled-Ameur To: u-boot@lists.denx.de Cc: khilman@baylibre.com, Keerthy , Amjad Ouled-Ameur Subject: [PATCH v2 04/10] linux: bitmap.h: Add find_next_zero_area function Date: Thu, 30 Sep 2021 18:21:05 +0200 Message-Id: <20210930162111.37566-5-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930162111.37566-1-aouledameur@baylibre.com> References: <20210930162111.37566-1-aouledameur@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Keerthy Add find_next_zero_area to fetch the next zero area in the map. Signed-off-by: Keerthy Signed-off-by: Amjad Ouled-Ameur --- (no changes since v1) include/linux/bitmap.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index dae4225be549..0a8503af9f14 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h @@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned long *addr, unsigned l (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) +static inline unsigned long +bitmap_find_next_zero_area(unsigned long *map, + unsigned long size, + unsigned long start, + unsigned int nr, unsigned long align_mask) +{ + unsigned long index, end, i; +again: + index = find_next_zero_bit(map, size, start); + + /* + * Align allocation + */ + index = (index + align_mask) & ~align_mask; + + end = index + nr; + if (end > size) + return end; + i = find_next_bit(map, end, index); + if (i < end) { + start = i + 1; + goto again; + } + return index; +} + static inline void bitmap_fill(unsigned long *dst, unsigned int nbits) { if (small_const_nbits(nbits)) { -- 2.25.1