* [PATCH RFC 0/2] Introduce BITS_MASK macro
@ 2013-10-31 11:53 srinivas.kandagatla
2013-10-31 11:53 ` [PATCH RFC 1/2] bitops: introduce " srinivas.kandagatla
2013-10-31 11:54 ` [PATCH RFC 2/2] regmap: move to using " srinivas.kandagatla
0 siblings, 2 replies; 5+ messages in thread
From: srinivas.kandagatla @ 2013-10-31 11:53 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, srinivas.kandagatla, Greg Kroah-Hartman
From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
This patch series introduces BITS_MASK macro which creates a mask for a given
lsb and msb bit locations. The usage of masks spread over mutiple bits is
becoming very common for example with regmap_update_bits kind of apis. Having a
common macro for this makes much sense and is clean and readable way to encode
the mask rather than having an hex number for a mask.
Second patch is to show an example usage of this new macro in regmap.
Comments ?
Thanks,
srini
Srinivas Kandagatla (2):
bitops: introduce BITS_MASK macro
regmap: move to using BITS_MASK macro
drivers/base/regmap/regmap.c | 3 +--
include/linux/bitops.h | 1 +
2 files changed, 2 insertions(+), 2 deletions(-)
--
1.7.6.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH RFC 1/2] bitops: introduce BITS_MASK macro
2013-10-31 11:53 [PATCH RFC 0/2] Introduce BITS_MASK macro srinivas.kandagatla
@ 2013-10-31 11:53 ` srinivas.kandagatla
2013-10-31 11:54 ` [PATCH RFC 2/2] regmap: move to using " srinivas.kandagatla
1 sibling, 0 replies; 5+ messages in thread
From: srinivas.kandagatla @ 2013-10-31 11:53 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, srinivas.kandagatla, Greg Kroah-Hartman
From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
This patch introduces BITS_MASK macro which creates a mask for a given
lsb and msb bit locations. The usage of masks spread over mutiple bits
is becoming very common for example with regmap_update_bits kind of
apis. Having a common macro for this makes much sense and is clean and
readable way to encode the mask rather than having an hex number for a
mask.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
include/linux/bitops.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a3b6b82..3ddce97 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -5,6 +5,7 @@
#ifdef __KERNEL__
#define BIT(nr) (1UL << (nr))
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
+#define BITS_MASK(lsb, msb) ((BIT(msb - lsb + 1) - 1) << lsb)
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
#define BITS_PER_BYTE 8
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
--
1.7.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH RFC 2/2] regmap: move to using BITS_MASK macro
2013-10-31 11:53 [PATCH RFC 0/2] Introduce BITS_MASK macro srinivas.kandagatla
2013-10-31 11:53 ` [PATCH RFC 1/2] bitops: introduce " srinivas.kandagatla
@ 2013-10-31 11:54 ` srinivas.kandagatla
2013-10-31 15:38 ` Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: srinivas.kandagatla @ 2013-10-31 11:54 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, srinivas.kandagatla, Greg Kroah-Hartman
From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
This patch uses the new BITS_MASK macro for generating mask for multiple
bits.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
---
drivers/base/regmap/regmap.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 7d689a1..7433939 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -816,11 +816,10 @@ EXPORT_SYMBOL_GPL(devm_regmap_init);
static void regmap_field_init(struct regmap_field *rm_field,
struct regmap *regmap, struct reg_field reg_field)
{
- int field_bits = reg_field.msb - reg_field.lsb + 1;
rm_field->regmap = regmap;
rm_field->reg = reg_field.reg;
rm_field->shift = reg_field.lsb;
- rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb);
+ rm_field->mask = BITS_MASK(reg_field.lsb, reg_field.msb);
}
/**
--
1.7.6.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 2/2] regmap: move to using BITS_MASK macro
2013-10-31 11:54 ` [PATCH RFC 2/2] regmap: move to using " srinivas.kandagatla
@ 2013-10-31 15:38 ` Mark Brown
2013-10-31 15:48 ` srinivas kandagatla
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2013-10-31 15:38 UTC (permalink / raw)
To: srinivas.kandagatla; +Cc: linux-kernel, Greg Kroah-Hartman
[-- Attachment #1: Type: text/plain, Size: 345 bytes --]
On Thu, Oct 31, 2013 at 11:54:01AM +0000, srinivas.kandagatla@st.com wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
>
> This patch uses the new BITS_MASK macro for generating mask for multiple
> bits.
Acked-by: Mark Brown <broonie@linaro.org>
Or I can apply both. There's plenty of other places this could be used.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 2/2] regmap: move to using BITS_MASK macro
2013-10-31 15:38 ` Mark Brown
@ 2013-10-31 15:48 ` srinivas kandagatla
0 siblings, 0 replies; 5+ messages in thread
From: srinivas kandagatla @ 2013-10-31 15:48 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Greg Kroah-Hartman
On 31/10/13 15:38, Mark Brown wrote:
> On Thu, Oct 31, 2013 at 11:54:01AM +0000, srinivas.kandagatla@st.com wrote:
>> From: Srinivas Kandagatla <srinivas.kandagatla@st.com>
>>
>> This patch uses the new BITS_MASK macro for generating mask for multiple
>> bits.
>
> Acked-by: Mark Brown <broonie@linaro.org>
Thanks Mark,
>
> Or I can apply both. There's plenty of other places this could be used.
>
It makes sense to take it via regmap tree as there is dependency on the
first patch.
Thanks,
srini
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-31 15:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-31 11:53 [PATCH RFC 0/2] Introduce BITS_MASK macro srinivas.kandagatla
2013-10-31 11:53 ` [PATCH RFC 1/2] bitops: introduce " srinivas.kandagatla
2013-10-31 11:54 ` [PATCH RFC 2/2] regmap: move to using " srinivas.kandagatla
2013-10-31 15:38 ` Mark Brown
2013-10-31 15:48 ` srinivas kandagatla
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).