All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro
@ 2015-10-01  2:23 Shraddha Barke
  2015-10-01  3:25 ` [Outreachy kernel] " Vaishali Thakkar
  2015-10-01  7:58 ` Julia Lawall
  0 siblings, 2 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-01  2:23 UTC (permalink / raw)
  To: outreachy-kernel

Use BIT()/GENMASK() macros for all register definitions instead of
hand-writing bit masks.

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
Changes in v2-
 Used GENMASK macro; covered more cases of BIT macro and updated 
 commit message

 drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 10fa372..a8049ef 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP		BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN		(1 << 7)
-#define AD7746_CAPSETUP_CIN2		(1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF		(1 << 5)
-#define AD7746_CAPSETUP_CACHOP		(1 << 0)
+#define AD7746_CAPSETUP_CAPEN		BIT(7)
+#define AD7746_CAPSETUP_CIN2		BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF		BIT(5)
+#define AD7746_CAPSETUP_CACHOP		BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN		(1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
-#define AD7746_VTSETUP_EXTREF		(1 << 4)
-#define AD7746_VTSETUP_VTSHORT		(1 << 1)
-#define AD7746_VTSETUP_VTCHOP		(1 << 0)
+#define AD7746_VTSETUP_VTEN		BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP	0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON	GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN	GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF		BIT(4)
+#define AD7746_VTSETUP_VTSHORT		BIT(1)
+#define AD7746_VTSETUP_VTCHOP		BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL		(1 << 7)
-#define AD7746_EXCSETUP_EXCON		(1 << 6)
-#define AD7746_EXCSETUP_EXCB		(1 << 5)
-#define AD7746_EXCSETUP_NEXCB		(1 << 4)
-#define AD7746_EXCSETUP_EXCA		(1 << 3)
-#define AD7746_EXCSETUP_NEXCA		(1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)	(((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL		BIT(7)
+#define AD7746_EXCSETUP_EXCON		BIT(6)
+#define AD7746_EXCSETUP_EXCB		BIT(5)
+#define AD7746_EXCSETUP_NEXCB		BIT(4)
+#define AD7746_EXCSETUP_EXCA		BIT(3)
+#define AD7746_EXCSETUP_NEXCA		BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)	GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)		((x) << 6)
 #define AD7746_CONF_CAPFS(x)		((x) << 3)
-#define AD7746_CONF_MODE_IDLE		(0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
-#define AD7746_CONF_MODE_PWRDN		(3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL	(6 << 0)
+#define AD7746_CONF_MODE_IDLE		0
+#define AD7746_CONF_MODE_CONT_CONV	GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV	GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN		GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL	GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL	GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN		(1 << 7)
+#define AD7746_CAPDAC_DACEN		BIT(7)
 #define AD7746_CAPDAC_DACP(x)		((x) & 0x7F)
 
 /*
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Outreachy kernel] [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro
  2015-10-01  2:23 [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro Shraddha Barke
@ 2015-10-01  3:25 ` Vaishali Thakkar
  2015-10-01  4:30   ` Shraddha Barke
  2015-10-01  7:58 ` Julia Lawall
  1 sibling, 1 reply; 6+ messages in thread
From: Vaishali Thakkar @ 2015-10-01  3:25 UTC (permalink / raw)
  To: Shraddha Barke; +Cc: outreachy-kernel

On Thu, Oct 1, 2015 at 7:53 AM, Shraddha Barke <shraddha.6596@gmail.com> wrote:
> Use BIT()/GENMASK() macros for all register definitions instead of
> hand-writing bit masks.

Hi Shraddha,

I think this should come as a patch series as you are replacing things with
two different macros. You can go for one patch to replace all cases with
BIT macro and another one to handle cases where you can use
GENMASK macro.

Thanks

> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> Changes in v2-
>  Used GENMASK macro; covered more cases of BIT macro and updated
>  commit message
>
>  drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
>  1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index 10fa372..a8049ef 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -52,42 +52,42 @@
>  #define AD7746_STATUS_RDYCAP           BIT(0)
>
>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
> -#define AD7746_CAPSETUP_CAPEN          (1 << 7)
> -#define AD7746_CAPSETUP_CIN2           (1 << 6) /* AD7746 only */
> -#define AD7746_CAPSETUP_CAPDIFF                (1 << 5)
> -#define AD7746_CAPSETUP_CACHOP         (1 << 0)
> +#define AD7746_CAPSETUP_CAPEN          BIT(7)
> +#define AD7746_CAPSETUP_CIN2           BIT(6) /* AD7746 only */
> +#define AD7746_CAPSETUP_CAPDIFF                BIT(5)
> +#define AD7746_CAPSETUP_CACHOP         BIT(0)
>
>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
> -#define AD7746_VTSETUP_VTEN            (1 << 7)
> -#define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
> -#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
> -#define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
> -#define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
> -#define AD7746_VTSETUP_EXTREF          (1 << 4)
> -#define AD7746_VTSETUP_VTSHORT         (1 << 1)
> -#define AD7746_VTSETUP_VTCHOP          (1 << 0)
> +#define AD7746_VTSETUP_VTEN            BIT(7)
> +#define AD7746_VTSETUP_VTMD_INT_TEMP   0
> +#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
> +#define AD7746_VTSETUP_VTMD_VDD_MON    GENMASK(6, 0)
> +#define AD7746_VTSETUP_VTMD_EXT_VIN    GENMASK(6, 5)
> +#define AD7746_VTSETUP_EXTREF          BIT(4)
> +#define AD7746_VTSETUP_VTSHORT         BIT(1)
> +#define AD7746_VTSETUP_VTCHOP          BIT(0)
>
>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
> -#define AD7746_EXCSETUP_CLKCTRL                (1 << 7)
> -#define AD7746_EXCSETUP_EXCON          (1 << 6)
> -#define AD7746_EXCSETUP_EXCB           (1 << 5)
> -#define AD7746_EXCSETUP_NEXCB          (1 << 4)
> -#define AD7746_EXCSETUP_EXCA           (1 << 3)
> -#define AD7746_EXCSETUP_NEXCA          (1 << 2)
> -#define AD7746_EXCSETUP_EXCLVL(x)      (((x) & 0x3) << 0)
> +#define AD7746_EXCSETUP_CLKCTRL                BIT(7)
> +#define AD7746_EXCSETUP_EXCON          BIT(6)
> +#define AD7746_EXCSETUP_EXCB           BIT(5)
> +#define AD7746_EXCSETUP_NEXCB          BIT(4)
> +#define AD7746_EXCSETUP_EXCA           BIT(3)
> +#define AD7746_EXCSETUP_NEXCA          BIT(2)
> +#define AD7746_EXCSETUP_EXCLVL(x)      GENMASK(((x) & 0x3), 0)
>
>  /* Config Register Bit Designations (AD7746_REG_CFG) */
>  #define AD7746_CONF_VTFS(x)            ((x) << 6)
>  #define AD7746_CONF_CAPFS(x)           ((x) << 3)
> -#define AD7746_CONF_MODE_IDLE          (0 << 0)
> -#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
> -#define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
> -#define AD7746_CONF_MODE_PWRDN         (3 << 0)
> -#define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
> -#define AD7746_CONF_MODE_GAIN_CAL      (6 << 0)
> +#define AD7746_CONF_MODE_IDLE          0
> +#define AD7746_CONF_MODE_CONT_CONV     GENMASK(1, 0)
> +#define AD7746_CONF_MODE_SINGLE_CONV   GENMASK(2, 0)
> +#define AD7746_CONF_MODE_PWRDN         GENMASK(3, 0)
> +#define AD7746_CONF_MODE_OFFS_CAL      GENMASK(5, 0)
> +#define AD7746_CONF_MODE_GAIN_CAL      GENMASK(6, 0)
>
>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
> -#define AD7746_CAPDAC_DACEN            (1 << 7)
> +#define AD7746_CAPDAC_DACEN            BIT(7)
>  #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
>
>  /*
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Vaishali


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Outreachy kernel] [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro
  2015-10-01  3:25 ` [Outreachy kernel] " Vaishali Thakkar
@ 2015-10-01  4:30   ` Shraddha Barke
  2015-10-01  4:45     ` Vaishali Thakkar
  0 siblings, 1 reply; 6+ messages in thread
From: Shraddha Barke @ 2015-10-01  4:30 UTC (permalink / raw)
  To: Vaishali Thakkar; +Cc: outreachy-kernel



On Thu, 1 Oct 2015, Vaishali Thakkar wrote:

> On Thu, Oct 1, 2015 at 7:53 AM, Shraddha Barke <shraddha.6596@gmail.com> wrote:
>> Use BIT()/GENMASK() macros for all register definitions instead of
>> hand-writing bit masks.
>
> Hi Shraddha,
>
> I think this should come as a patch series as you are replacing things with
> two different macros. You can go for one patch to replace all cases with
> BIT macro and another one to handle cases where you can use

Thanks Vaishali .Can I handle cases of BIT macro in multiple files in a
single patch?

Shraddha

> GENMASK macro.
>
> Thanks
>
>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>> ---
>> Changes in v2-
>>  Used GENMASK macro; covered more cases of BIT macro and updated
>>  commit message
>>
>>  drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
>>  1 file changed, 26 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
>> index 10fa372..a8049ef 100644
>> --- a/drivers/staging/iio/cdc/ad7746.c
>> +++ b/drivers/staging/iio/cdc/ad7746.c
>> @@ -52,42 +52,42 @@
>>  #define AD7746_STATUS_RDYCAP           BIT(0)
>>
>>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
>> -#define AD7746_CAPSETUP_CAPEN          (1 << 7)
>> -#define AD7746_CAPSETUP_CIN2           (1 << 6) /* AD7746 only */
>> -#define AD7746_CAPSETUP_CAPDIFF                (1 << 5)
>> -#define AD7746_CAPSETUP_CACHOP         (1 << 0)
>> +#define AD7746_CAPSETUP_CAPEN          BIT(7)
>> +#define AD7746_CAPSETUP_CIN2           BIT(6) /* AD7746 only */
>> +#define AD7746_CAPSETUP_CAPDIFF                BIT(5)
>> +#define AD7746_CAPSETUP_CACHOP         BIT(0)
>>
>>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
>> -#define AD7746_VTSETUP_VTEN            (1 << 7)
>> -#define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
>> -#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
>> -#define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
>> -#define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
>> -#define AD7746_VTSETUP_EXTREF          (1 << 4)
>> -#define AD7746_VTSETUP_VTSHORT         (1 << 1)
>> -#define AD7746_VTSETUP_VTCHOP          (1 << 0)
>> +#define AD7746_VTSETUP_VTEN            BIT(7)
>> +#define AD7746_VTSETUP_VTMD_INT_TEMP   0
>> +#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
>> +#define AD7746_VTSETUP_VTMD_VDD_MON    GENMASK(6, 0)
>> +#define AD7746_VTSETUP_VTMD_EXT_VIN    GENMASK(6, 5)
>> +#define AD7746_VTSETUP_EXTREF          BIT(4)
>> +#define AD7746_VTSETUP_VTSHORT         BIT(1)
>> +#define AD7746_VTSETUP_VTCHOP          BIT(0)
>>
>>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
>> -#define AD7746_EXCSETUP_CLKCTRL                (1 << 7)
>> -#define AD7746_EXCSETUP_EXCON          (1 << 6)
>> -#define AD7746_EXCSETUP_EXCB           (1 << 5)
>> -#define AD7746_EXCSETUP_NEXCB          (1 << 4)
>> -#define AD7746_EXCSETUP_EXCA           (1 << 3)
>> -#define AD7746_EXCSETUP_NEXCA          (1 << 2)
>> -#define AD7746_EXCSETUP_EXCLVL(x)      (((x) & 0x3) << 0)
>> +#define AD7746_EXCSETUP_CLKCTRL                BIT(7)
>> +#define AD7746_EXCSETUP_EXCON          BIT(6)
>> +#define AD7746_EXCSETUP_EXCB           BIT(5)
>> +#define AD7746_EXCSETUP_NEXCB          BIT(4)
>> +#define AD7746_EXCSETUP_EXCA           BIT(3)
>> +#define AD7746_EXCSETUP_NEXCA          BIT(2)
>> +#define AD7746_EXCSETUP_EXCLVL(x)      GENMASK(((x) & 0x3), 0)
>>
>>  /* Config Register Bit Designations (AD7746_REG_CFG) */
>>  #define AD7746_CONF_VTFS(x)            ((x) << 6)
>>  #define AD7746_CONF_CAPFS(x)           ((x) << 3)
>> -#define AD7746_CONF_MODE_IDLE          (0 << 0)
>> -#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
>> -#define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
>> -#define AD7746_CONF_MODE_PWRDN         (3 << 0)
>> -#define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
>> -#define AD7746_CONF_MODE_GAIN_CAL      (6 << 0)
>> +#define AD7746_CONF_MODE_IDLE          0
>> +#define AD7746_CONF_MODE_CONT_CONV     GENMASK(1, 0)
>> +#define AD7746_CONF_MODE_SINGLE_CONV   GENMASK(2, 0)
>> +#define AD7746_CONF_MODE_PWRDN         GENMASK(3, 0)
>> +#define AD7746_CONF_MODE_OFFS_CAL      GENMASK(5, 0)
>> +#define AD7746_CONF_MODE_GAIN_CAL      GENMASK(6, 0)
>>
>>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
>> -#define AD7746_CAPDAC_DACEN            (1 << 7)
>> +#define AD7746_CAPDAC_DACEN            BIT(7)
>>  #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
>>
>>  /*
>> --
>> 2.1.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> -- 
> Vaishali
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Outreachy kernel] [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro
  2015-10-01  4:30   ` Shraddha Barke
@ 2015-10-01  4:45     ` Vaishali Thakkar
  0 siblings, 0 replies; 6+ messages in thread
From: Vaishali Thakkar @ 2015-10-01  4:45 UTC (permalink / raw)
  To: Shraddha Barke; +Cc: outreachy-kernel

On Thu, Oct 1, 2015 at 10:00 AM, Shraddha Barke <shraddha.6596@gmail.com> wrote:
>
>
> On Thu, 1 Oct 2015, Vaishali Thakkar wrote:
>
>> On Thu, Oct 1, 2015 at 7:53 AM, Shraddha Barke <shraddha.6596@gmail.com>
>> wrote:
>>>
>>> Use BIT()/GENMASK() macros for all register definitions instead of
>>> hand-writing bit masks.
>>
>>
>> Hi Shraddha,
>>
>> I think this should come as a patch series as you are replacing things
>> with
>> two different macros. You can go for one patch to replace all cases with
>> BIT macro and another one to handle cases where you can use
>
>
> Thanks Vaishali .Can I handle cases of BIT macro in multiple files in a
> single patch?

Yes, you can. But only when those files belongs to single directory.
eg. You can handle files which comes under drivers/staging/iio/cdc/ at
a single point of time. Like you did here:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=64ffdc383b18e66c3698fff05ea693f4346cfbf9

Although for this patch, I think just sending a patch series
with v3 is preferable. You can go for sending separate patches for
other such cases.

> Shraddha
>
>
>> GENMASK macro.
>>
>> Thanks
>>
>>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>>> ---
>>> Changes in v2-
>>>  Used GENMASK macro; covered more cases of BIT macro and updated
>>>  commit message
>>>
>>>  drivers/staging/iio/cdc/ad7746.c | 52
>>> ++++++++++++++++++++--------------------
>>>  1 file changed, 26 insertions(+), 26 deletions(-)
>>>
>>> diff --git a/drivers/staging/iio/cdc/ad7746.c
>>> b/drivers/staging/iio/cdc/ad7746.c
>>> index 10fa372..a8049ef 100644
>>> --- a/drivers/staging/iio/cdc/ad7746.c
>>> +++ b/drivers/staging/iio/cdc/ad7746.c
>>> @@ -52,42 +52,42 @@
>>>  #define AD7746_STATUS_RDYCAP           BIT(0)
>>>
>>>  /* Capacitive Channel Setup Register Bit Designations
>>> (AD7746_REG_CAP_SETUP) */
>>> -#define AD7746_CAPSETUP_CAPEN          (1 << 7)
>>> -#define AD7746_CAPSETUP_CIN2           (1 << 6) /* AD7746 only */
>>> -#define AD7746_CAPSETUP_CAPDIFF                (1 << 5)
>>> -#define AD7746_CAPSETUP_CACHOP         (1 << 0)
>>> +#define AD7746_CAPSETUP_CAPEN          BIT(7)
>>> +#define AD7746_CAPSETUP_CIN2           BIT(6) /* AD7746 only */
>>> +#define AD7746_CAPSETUP_CAPDIFF                BIT(5)
>>> +#define AD7746_CAPSETUP_CACHOP         BIT(0)
>>>
>>>  /* Voltage/Temperature Setup Register Bit Designations
>>> (AD7746_REG_VT_SETUP) */
>>> -#define AD7746_VTSETUP_VTEN            (1 << 7)
>>> -#define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
>>> -#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
>>> -#define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
>>> -#define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
>>> -#define AD7746_VTSETUP_EXTREF          (1 << 4)
>>> -#define AD7746_VTSETUP_VTSHORT         (1 << 1)
>>> -#define AD7746_VTSETUP_VTCHOP          (1 << 0)
>>> +#define AD7746_VTSETUP_VTEN            BIT(7)
>>> +#define AD7746_VTSETUP_VTMD_INT_TEMP   0
>>> +#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
>>> +#define AD7746_VTSETUP_VTMD_VDD_MON    GENMASK(6, 0)
>>> +#define AD7746_VTSETUP_VTMD_EXT_VIN    GENMASK(6, 5)
>>> +#define AD7746_VTSETUP_EXTREF          BIT(4)
>>> +#define AD7746_VTSETUP_VTSHORT         BIT(1)
>>> +#define AD7746_VTSETUP_VTCHOP          BIT(0)
>>>
>>>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
>>> -#define AD7746_EXCSETUP_CLKCTRL                (1 << 7)
>>> -#define AD7746_EXCSETUP_EXCON          (1 << 6)
>>> -#define AD7746_EXCSETUP_EXCB           (1 << 5)
>>> -#define AD7746_EXCSETUP_NEXCB          (1 << 4)
>>> -#define AD7746_EXCSETUP_EXCA           (1 << 3)
>>> -#define AD7746_EXCSETUP_NEXCA          (1 << 2)
>>> -#define AD7746_EXCSETUP_EXCLVL(x)      (((x) & 0x3) << 0)
>>> +#define AD7746_EXCSETUP_CLKCTRL                BIT(7)
>>> +#define AD7746_EXCSETUP_EXCON          BIT(6)
>>> +#define AD7746_EXCSETUP_EXCB           BIT(5)
>>> +#define AD7746_EXCSETUP_NEXCB          BIT(4)
>>> +#define AD7746_EXCSETUP_EXCA           BIT(3)
>>> +#define AD7746_EXCSETUP_NEXCA          BIT(2)
>>> +#define AD7746_EXCSETUP_EXCLVL(x)      GENMASK(((x) & 0x3), 0)
>>>
>>>  /* Config Register Bit Designations (AD7746_REG_CFG) */
>>>  #define AD7746_CONF_VTFS(x)            ((x) << 6)
>>>  #define AD7746_CONF_CAPFS(x)           ((x) << 3)
>>> -#define AD7746_CONF_MODE_IDLE          (0 << 0)
>>> -#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
>>> -#define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
>>> -#define AD7746_CONF_MODE_PWRDN         (3 << 0)
>>> -#define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
>>> -#define AD7746_CONF_MODE_GAIN_CAL      (6 << 0)
>>> +#define AD7746_CONF_MODE_IDLE          0
>>> +#define AD7746_CONF_MODE_CONT_CONV     GENMASK(1, 0)
>>> +#define AD7746_CONF_MODE_SINGLE_CONV   GENMASK(2, 0)
>>> +#define AD7746_CONF_MODE_PWRDN         GENMASK(3, 0)
>>> +#define AD7746_CONF_MODE_OFFS_CAL      GENMASK(5, 0)
>>> +#define AD7746_CONF_MODE_GAIN_CAL      GENMASK(6, 0)
>>>
>>>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
>>> -#define AD7746_CAPDAC_DACEN            (1 << 7)
>>> +#define AD7746_CAPDAC_DACEN            BIT(7)
>>>  #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
>>>
>>>  /*
>>> --
>>> 2.1.4
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "outreachy-kernel" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to outreachy-kernel+unsubscribe@googlegroups.com.
>>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> Vaishali
>>
>



-- 
Vaishali


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Outreachy kernel] [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro
  2015-10-01  2:23 [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro Shraddha Barke
  2015-10-01  3:25 ` [Outreachy kernel] " Vaishali Thakkar
@ 2015-10-01  7:58 ` Julia Lawall
  2015-10-01  8:16   ` Shraddha Barke
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2015-10-01  7:58 UTC (permalink / raw)
  To: Shraddha Barke; +Cc: outreachy-kernel



On Thu, 1 Oct 2015, Shraddha Barke wrote:

> Use BIT()/GENMASK() macros for all register definitions instead of
> hand-writing bit masks.

It would be nice to fix the alignment at various palaces as well.

julia

> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
> ---
> Changes in v2-
>  Used GENMASK macro; covered more cases of BIT macro and updated
>  commit message
>
>  drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
>  1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index 10fa372..a8049ef 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -52,42 +52,42 @@
>  #define AD7746_STATUS_RDYCAP		BIT(0)
>
>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
> -#define AD7746_CAPSETUP_CAPEN		(1 << 7)
> -#define AD7746_CAPSETUP_CIN2		(1 << 6) /* AD7746 only */
> -#define AD7746_CAPSETUP_CAPDIFF		(1 << 5)
> -#define AD7746_CAPSETUP_CACHOP		(1 << 0)
> +#define AD7746_CAPSETUP_CAPEN		BIT(7)
> +#define AD7746_CAPSETUP_CIN2		BIT(6) /* AD7746 only */
> +#define AD7746_CAPSETUP_CAPDIFF		BIT(5)
> +#define AD7746_CAPSETUP_CACHOP		BIT(0)
>
>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
> -#define AD7746_VTSETUP_VTEN		(1 << 7)
> -#define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
> -#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
> -#define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
> -#define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
> -#define AD7746_VTSETUP_EXTREF		(1 << 4)
> -#define AD7746_VTSETUP_VTSHORT		(1 << 1)
> -#define AD7746_VTSETUP_VTCHOP		(1 << 0)
> +#define AD7746_VTSETUP_VTEN		BIT(7)
> +#define AD7746_VTSETUP_VTMD_INT_TEMP	0
> +#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
> +#define AD7746_VTSETUP_VTMD_VDD_MON	GENMASK(6, 0)
> +#define AD7746_VTSETUP_VTMD_EXT_VIN	GENMASK(6, 5)
> +#define AD7746_VTSETUP_EXTREF		BIT(4)
> +#define AD7746_VTSETUP_VTSHORT		BIT(1)
> +#define AD7746_VTSETUP_VTCHOP		BIT(0)
>
>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
> -#define AD7746_EXCSETUP_CLKCTRL		(1 << 7)
> -#define AD7746_EXCSETUP_EXCON		(1 << 6)
> -#define AD7746_EXCSETUP_EXCB		(1 << 5)
> -#define AD7746_EXCSETUP_NEXCB		(1 << 4)
> -#define AD7746_EXCSETUP_EXCA		(1 << 3)
> -#define AD7746_EXCSETUP_NEXCA		(1 << 2)
> -#define AD7746_EXCSETUP_EXCLVL(x)	(((x) & 0x3) << 0)
> +#define AD7746_EXCSETUP_CLKCTRL		BIT(7)
> +#define AD7746_EXCSETUP_EXCON		BIT(6)
> +#define AD7746_EXCSETUP_EXCB		BIT(5)
> +#define AD7746_EXCSETUP_NEXCB		BIT(4)
> +#define AD7746_EXCSETUP_EXCA		BIT(3)
> +#define AD7746_EXCSETUP_NEXCA		BIT(2)
> +#define AD7746_EXCSETUP_EXCLVL(x)	GENMASK(((x) & 0x3), 0)
>
>  /* Config Register Bit Designations (AD7746_REG_CFG) */
>  #define AD7746_CONF_VTFS(x)		((x) << 6)
>  #define AD7746_CONF_CAPFS(x)		((x) << 3)
> -#define AD7746_CONF_MODE_IDLE		(0 << 0)
> -#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
> -#define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
> -#define AD7746_CONF_MODE_PWRDN		(3 << 0)
> -#define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
> -#define AD7746_CONF_MODE_GAIN_CAL	(6 << 0)
> +#define AD7746_CONF_MODE_IDLE		0
> +#define AD7746_CONF_MODE_CONT_CONV	GENMASK(1, 0)
> +#define AD7746_CONF_MODE_SINGLE_CONV	GENMASK(2, 0)
> +#define AD7746_CONF_MODE_PWRDN		GENMASK(3, 0)
> +#define AD7746_CONF_MODE_OFFS_CAL	GENMASK(5, 0)
> +#define AD7746_CONF_MODE_GAIN_CAL	GENMASK(6, 0)
>
>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
> -#define AD7746_CAPDAC_DACEN		(1 << 7)
> +#define AD7746_CAPDAC_DACEN		BIT(7)
>  #define AD7746_CAPDAC_DACP(x)		((x) & 0x7F)
>
>  /*
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Outreachy kernel] [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro
  2015-10-01  7:58 ` Julia Lawall
@ 2015-10-01  8:16   ` Shraddha Barke
  0 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-01  8:16 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Shraddha Barke, outreachy-kernel



On Thu, 1 Oct 2015, Julia Lawall wrote:

>
>
> On Thu, 1 Oct 2015, Shraddha Barke wrote:
>
>> Use BIT()/GENMASK() macros for all register definitions instead of
>> hand-writing bit masks.
>
> It would be nice to fix the alignment at various palaces as well.

Hello Julia,
  Yes I know it looks messy. But I'm not able to figure out how I should 
fix this alignment issue. I have faced this problem while sending patches
before as well. I use git-send-email for sending patches.

Shraddha.

>
> julia
>
>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>> ---
>> Changes in v2-
>>  Used GENMASK macro; covered more cases of BIT macro and updated
>>  commit message
>>
>>  drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
>>  1 file changed, 26 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
>> index 10fa372..a8049ef 100644
>> --- a/drivers/staging/iio/cdc/ad7746.c
>> +++ b/drivers/staging/iio/cdc/ad7746.c
>> @@ -52,42 +52,42 @@
>>  #define AD7746_STATUS_RDYCAP		BIT(0)
>>
>>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
>> -#define AD7746_CAPSETUP_CAPEN		(1 << 7)
>> -#define AD7746_CAPSETUP_CIN2		(1 << 6) /* AD7746 only */
>> -#define AD7746_CAPSETUP_CAPDIFF		(1 << 5)
>> -#define AD7746_CAPSETUP_CACHOP		(1 << 0)
>> +#define AD7746_CAPSETUP_CAPEN		BIT(7)
>> +#define AD7746_CAPSETUP_CIN2		BIT(6) /* AD7746 only */
>> +#define AD7746_CAPSETUP_CAPDIFF		BIT(5)
>> +#define AD7746_CAPSETUP_CACHOP		BIT(0)
>>
>>  /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
>> -#define AD7746_VTSETUP_VTEN		(1 << 7)
>> -#define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
>> -#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
>> -#define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
>> -#define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
>> -#define AD7746_VTSETUP_EXTREF		(1 << 4)
>> -#define AD7746_VTSETUP_VTSHORT		(1 << 1)
>> -#define AD7746_VTSETUP_VTCHOP		(1 << 0)
>> +#define AD7746_VTSETUP_VTEN		BIT(7)
>> +#define AD7746_VTSETUP_VTMD_INT_TEMP	0
>> +#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
>> +#define AD7746_VTSETUP_VTMD_VDD_MON	GENMASK(6, 0)
>> +#define AD7746_VTSETUP_VTMD_EXT_VIN	GENMASK(6, 5)
>> +#define AD7746_VTSETUP_EXTREF		BIT(4)
>> +#define AD7746_VTSETUP_VTSHORT		BIT(1)
>> +#define AD7746_VTSETUP_VTCHOP		BIT(0)
>>
>>  /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
>> -#define AD7746_EXCSETUP_CLKCTRL		(1 << 7)
>> -#define AD7746_EXCSETUP_EXCON		(1 << 6)
>> -#define AD7746_EXCSETUP_EXCB		(1 << 5)
>> -#define AD7746_EXCSETUP_NEXCB		(1 << 4)
>> -#define AD7746_EXCSETUP_EXCA		(1 << 3)
>> -#define AD7746_EXCSETUP_NEXCA		(1 << 2)
>> -#define AD7746_EXCSETUP_EXCLVL(x)	(((x) & 0x3) << 0)
>> +#define AD7746_EXCSETUP_CLKCTRL		BIT(7)
>> +#define AD7746_EXCSETUP_EXCON		BIT(6)
>> +#define AD7746_EXCSETUP_EXCB		BIT(5)
>> +#define AD7746_EXCSETUP_NEXCB		BIT(4)
>> +#define AD7746_EXCSETUP_EXCA		BIT(3)
>> +#define AD7746_EXCSETUP_NEXCA		BIT(2)
>> +#define AD7746_EXCSETUP_EXCLVL(x)	GENMASK(((x) & 0x3), 0)
>>
>>  /* Config Register Bit Designations (AD7746_REG_CFG) */
>>  #define AD7746_CONF_VTFS(x)		((x) << 6)
>>  #define AD7746_CONF_CAPFS(x)		((x) << 3)
>> -#define AD7746_CONF_MODE_IDLE		(0 << 0)
>> -#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
>> -#define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
>> -#define AD7746_CONF_MODE_PWRDN		(3 << 0)
>> -#define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
>> -#define AD7746_CONF_MODE_GAIN_CAL	(6 << 0)
>> +#define AD7746_CONF_MODE_IDLE		0
>> +#define AD7746_CONF_MODE_CONT_CONV	GENMASK(1, 0)
>> +#define AD7746_CONF_MODE_SINGLE_CONV	GENMASK(2, 0)
>> +#define AD7746_CONF_MODE_PWRDN		GENMASK(3, 0)
>> +#define AD7746_CONF_MODE_OFFS_CAL	GENMASK(5, 0)
>> +#define AD7746_CONF_MODE_GAIN_CAL	GENMASK(6, 0)
>>
>>  /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
>> -#define AD7746_CAPDAC_DACEN		(1 << 7)
>> +#define AD7746_CAPDAC_DACEN		BIT(7)
>>  #define AD7746_CAPDAC_DACP(x)		((x) & 0x7F)
>>
>>  /*
>> --
>> 2.1.4
>>
>> --
>> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
>> To post to this group, send email to outreachy-kernel@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-10-01  8:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01  2:23 [PATCH v2] Staging: iio: cdc: Use BIT and GENMASK macro Shraddha Barke
2015-10-01  3:25 ` [Outreachy kernel] " Vaishali Thakkar
2015-10-01  4:30   ` Shraddha Barke
2015-10-01  4:45     ` Vaishali Thakkar
2015-10-01  7:58 ` Julia Lawall
2015-10-01  8:16   ` Shraddha Barke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.