u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Amjad Ouled-Ameur <aouledameur@baylibre.com>
To: u-boot@lists.denx.de
Cc: Keerthy <j-keerthy@ti.com>, Amjad Ouled-Ameur <aouledameur@baylibre.com>
Subject: [PATCH 04/10] linux: bitmap.h: Add find_next_zero_area function
Date: Thu, 23 Sep 2021 18:46:43 +0200	[thread overview]
Message-ID: <20210923164649.214770-5-aouledameur@baylibre.com> (raw)
In-Reply-To: <20210923164649.214770-1-aouledameur@baylibre.com>

From: Keerthy <j-keerthy@ti.com>

Add find_next_zero_area to fetch the next zero area in the map.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
---

 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


  parent reply	other threads:[~2021-09-23 16:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23 16:46 [PATCH 00/10] dra7: bring up and support IPU load/start Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 01/10] reset: dra7: Add a reset driver Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 02/10] arm: mach-omap2: load/start remoteproc IPU1/IPU2 Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 03/10] drivers: misc: Makefile: Enable fs_loader compilation at SPL Level Amjad Ouled-Ameur
2021-09-23 16:46 ` Amjad Ouled-Ameur [this message]
2021-09-23 16:46 ` [PATCH 05/10] remoteproc: uclass: Add remoteproc resource handling helpers Amjad Ouled-Ameur
2021-09-24  2:49   ` Simon Glass
2021-09-23 16:46 ` [PATCH 06/10] remoteproc: ipu: Add driver to bring up ipu Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 07/10] dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot related nodes Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 08/10] arm: dts: dra7: Add ipu and " Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 09/10] arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes Amjad Ouled-Ameur
2021-09-23 16:46 ` [PATCH 10/10] dts: am57xx*: " Amjad Ouled-Ameur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210923164649.214770-5-aouledameur@baylibre.com \
    --to=aouledameur@baylibre.com \
    --cc=j-keerthy@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).