diff mbox

[for-4.7,v2,1/2] xen/bitops: Introduce GENMASK to generate mask

Message ID 1461340713-9587-2-git-send-email-julien.grall@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Julien Grall April 22, 2016, 3:58 p.m. UTC
The code has been imported from the header include/linux/bitops.h in
Linux v4.6-rc3.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>

---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>

    Changes in v2:
        - Remove GENMASK_ULL
        - Add Stefano's acked-by
---
 xen/include/xen/bitops.h | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jan Beulich April 22, 2016, 4:07 p.m. UTC | #1
>>> On 22.04.16 at 17:58, <julien.grall@arm.com> wrote:
> The code has been imported from the header include/linux/bitops.h in
> Linux v4.6-rc3.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> Acked-by: Stefano Stabellini <sstabellini@kernel.org>

And just to double check - Stefano, this ack was meant also as a
REST maintainer, not just an ARM one (as the latter was the
context it was originally given in)?

Jan
Stefano Stabellini April 22, 2016, 4:15 p.m. UTC | #2
On Fri, 22 Apr 2016, Jan Beulich wrote:
> >>> On 22.04.16 at 17:58, <julien.grall@arm.com> wrote:
> > The code has been imported from the header include/linux/bitops.h in
> > Linux v4.6-rc3.
> > 
> > Signed-off-by: Julien Grall <julien.grall@arm.com>
> > Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> And just to double check - Stefano, this ack was meant also as a
> REST maintainer, not just an ARM one (as the latter was the
> context it was originally given in)?

Yeah, the macro is OK for me.

It is just a macro - we don't have to introduce it if you dislike it, we
could simply explode it in xen/include/asm-arm/processor.h. On the other
hand, if you don't have an opinion about it, I would go ahead with this
patch. I am happy either way.
Ian Jackson April 22, 2016, 5:18 p.m. UTC | #3
Jan Beulich writes ("Re: [for-4.7 v2 1/2] xen/bitops: Introduce GENMASK to generate mask"):
> On 22.04.16 at 17:58, <julien.grall@arm.com> wrote:
> > The code has been imported from the header include/linux/bitops.h in
> > Linux v4.6-rc3.
> > 
> > Signed-off-by: Julien Grall <julien.grall@arm.com>
> > Acked-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> And just to double check - Stefano, this ack was meant also as a
> REST maintainer, not just an ARM one (as the latter was the
> context it was originally given in)?

For what it's worth, on the matter of taste I agree with Julien.
Having read the occasional ARM manual, the proposed macro will make it
much easier to check that the code matches the book.

Ian.
diff mbox

Patch

diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index cb56f24..bd0883a 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -3,6 +3,14 @@ 
 #include <asm/types.h>
 
 /*
+ * Create a contiguous bitmask starting at bit position @l and ending at
+ * position @h. For example
+ * GENMASK(30, 21) gives us the 32bit vector 0x01fe00000.
+ */
+#define GENMASK(h, l) \
+    (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+
+/*
  * ffs: find first bit set. This is defined the same way as
  * the libc and compiler builtin ffs routines, therefore
  * differs in spirit from the above ffz (man ffs).