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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1095CC433EF for ; Tue, 18 Jan 2022 10:14:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B3788381C; Tue, 18 Jan 2022 11:14:12 +0100 (CET) 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="uzPg63t5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4695383281; Tue, 18 Jan 2022 11:13:53 +0100 (CET) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 9270C83810 for ; Tue, 18 Jan 2022 11:13:43 +0100 (CET) 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-x32e.google.com with SMTP id i187-20020a1c3bc4000000b0034d2ed1be2aso3026247wma.1 for ; Tue, 18 Jan 2022 02:13:43 -0800 (PST) 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=uzPg63t59uLv5k1BApjQ0yurdIZyai4KDbe708RC3r6byq+tUdSRJRugc3Ku0j6FnT yjxgxcppRMK3I4S65NBxSypJGtVg1dEAvqdy486k62QTeduldKnJ4jrNbbegcMTEbVkT O5DX2eYN5claj3whA5ZIQgEK9ly+VHkEaOtGZgik69bDNMAk0s6XF6cuL6ZvUYNGBzX5 DmanVED2+RfM6/SeCx/boEJPwg+ZlVNsB7paUmUHEbdI/5Im17mVVEh2vWMYZNcTV+Kr 6hb7M3Xz2U6B5t+bO+5W0iKr6Uw/8y95s+Ru2Z5Zttmu/gRh45Pwi7B65Pg6sYUKLhIu jIow== 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=AQD6uZvN2GtOKRBHhe3F+PmhJgMxzIop/JpGrK07hiswjOPR0gcin1pqwGwkTcbrax rcUFyAf9I791ws5ejRJNMZSHjQWQihm+OD0Wb0segNXYGxv+uGEadCRwcD9D9NmBPu8a VghwGB5SvOhy/i8jtj1a7SOHAm1Q9LkjnRoo+mky6tYc8n45YqNZHzrpyl/LFsDBRym7 KvyOoC16e+a6gsz3MaddEQKr/cfMJQPQOqPC16l0/OvgVyt/4Ccnfrc0A4drXPJcgJ1e xlEesAmQGPLR9Ue+cCgTrAEhtzdJmiNPsBhIU9Tlr+NP2+1HVUTfJWp4fkhrKAxz4G7k tKJA== X-Gm-Message-State: AOAM532p2mszS4lVM/ZW0KHlgkdtNBFnSLHdmT+4hnkoTFWTJzL1XpfH qGEmaOdAilCFY2OrQw/OAbCz/WpFxXwmLg== X-Google-Smtp-Source: ABdhPJxusNSU+J4J2ggvrakYS7zRbdNSTBsthjvCWf3mTV3VGb/Xhd/2dS3o9dSXdYwfQ43LrWJ/zw== X-Received: by 2002:a5d:6250:: with SMTP id m16mr18409993wrv.412.1642500823225; Tue, 18 Jan 2022 02:13:43 -0800 (PST) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id f16sm2213622wmg.48.2022.01.18.02.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 02:13:42 -0800 (PST) From: Amjad Ouled-Ameur To: u-boot@lists.denx.de Cc: khilman@baylibre.com, Keerthy , Amjad Ouled-Ameur Subject: [PATCH v3 05/11] linux: bitmap.h: Add find_next_zero_area function Date: Tue, 18 Jan 2022 11:12:43 +0100 Message-Id: <20220118101249.87031-6-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118101249.87031-1-aouledameur@baylibre.com> References: <20220118101249.87031-1-aouledameur@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.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