From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [RFC PATCH v3 01/18] xen/arm: Add bitmap_find_next_zero_area helper function Date: Mon, 22 Jun 2015 15:14:03 +0100 Message-ID: <5588182B.6050702@citrix.com> References: <1434974517-12136-1-git-send-email-vijay.kilari@gmail.com> <1434974517-12136-2-git-send-email-vijay.kilari@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1434974517-12136-2-git-send-email-vijay.kilari@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: vijay.kilari@gmail.com, Ian.Campbell@citrix.com, julien.grall@citrix.com, stefano.stabellini@eu.citrix.com, stefano.stabellini@citrix.com, tim@xen.org, xen-devel@lists.xen.org Cc: Prasun.Kapoor@caviumnetworks.com, Vijaya Kumar K , manish.jaggi@caviumnetworks.com List-Id: xen-devel@lists.xenproject.org Hi, Please include all the relevant maintainers. See scripts/get_maintainers.pl. On 22/06/15 13:01, vijay.kilari@gmail.com wrote: > From: Vijaya Kumar K > > bitmap_find_next_zero_area helper function will be used > by physical ITS driver imported from linux > > Signed-off-by: Vijaya Kumar K > --- > v3: Moved changes to xen/common/bitmap.c and > xen/include/xen/bitmap.h > --- > xen/common/bitmap.c | 39 +++++++++++++++++++++++++++++++++++++++ > xen/include/xen/bitmap.h | 5 +++++ > 2 files changed, 44 insertions(+) > > diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c > index 61d1ea4..ba060b2 100644 > --- a/xen/common/bitmap.c > +++ b/xen/common/bitmap.c > @@ -489,6 +489,45 @@ int bitmap_allocate_region(unsigned long *bitmap, int pos, int order) > } > EXPORT_SYMBOL(bitmap_allocate_region); > > +/* > + * bitmap_find_next_zero_area - find a contiguous aligned zero area > + * @map: The address to base the search on > + * @size: The bitmap size in bits > + * @start: The bitnumber to start searching at > + * @nr: The number of zeroed bits we're looking for > + * @align_mask: Alignment mask for zero area > + * > + * The @align_mask should be one less than a power of 2; the effect is that > + * the bit offset of all zero areas this function finds is multiples of that > + * power of 2. A @align_mask of 0 means no alignment is required. > + */ > +#define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) This is not bitmap specific, I would move this macro in lib.h > +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 = ALIGN_MASK(index, 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; > +} > +EXPORT_SYMBOL(bitmap_find_next_zero_area); > + bitmap.c is using Linux coding style which include hard tabs. Please retain them. Regards, -- Julien Grall