[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20131017063059.GB14946@gchen.bj.intel.com>
Date: Thu, 17 Oct 2013 02:30:59 -0400
From: Chen Gong <gong.chen@...ux.intel.com>
To: Joe Perches <joe@...ches.com>
Cc: tony.luck@...el.com, bp@...en8.de, naveen.n.rao@...ux.vnet.ibm.com,
m.chehab@...sung.com, arozansk@...hat.com,
linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
Thomas Winischhofer <thomas@...ischhofer.net>,
Jean-Christophe Plagniol-Villard <plagnioj@...osoft.com>,
Tomi Valkeinen <tomi.valkeinen@...com>
Subject: Re: [PATCH v2 3/9] bitops: Introduce a more generic BITMASK macro
On Wed, Oct 16, 2013 at 07:59:09PM -0700, Joe Perches wrote:
> Date: Wed, 16 Oct 2013 19:59:09 -0700
> From: Joe Perches <joe@...ches.com>
> To: "Chen, Gong" <gong.chen@...ux.intel.com>
> Cc: tony.luck@...el.com, bp@...en8.de, naveen.n.rao@...ux.vnet.ibm.com,
> m.chehab@...sung.com, arozansk@...hat.com, linux-acpi@...r.kernel.org,
> linux-kernel@...r.kernel.org, Thomas Winischhofer
> <thomas@...ischhofer.net>, Jean-Christophe Plagniol-Villard
> <plagnioj@...osoft.com>, Tomi Valkeinen <tomi.valkeinen@...com>
> Subject: Re: [PATCH v2 3/9] bitops: Introduce a more generic BITMASK macro
> X-Mailer: Evolution 3.6.4-0ubuntu1
>
> On Wed, 2013-10-16 at 10:56 -0400, Chen, Gong wrote:
> > GENMASK is used to create a contiguous bitmask([hi:lo]). It is
> > implemented twice in current kernel. One is in EDAC driver, the other
> > is in SiS/XGI FB driver. Move it to a more generic place for other
> > usage.
> []
> > diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> []
> > @@ -10,6 +10,14 @@
> > #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
> > #endif
> >
> > +/*
> > + * Create a contiguous bitmask starting at bit position @l and ending at
> > + * position @h. For example
> > + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
>
> ull
>
> > + */
> > +#define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l))
> > +#define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
>
>
> Maybe add a
>
> BUILD_BUG_ON(__builtin_constant_p(l) && __builtin_constant_p(h) && \
> (h) < (l))
>
No, if so, users can't use variables for this macro.
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists