Re: [PATCH] staging: vme: Use BIT macro for bit definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 15, 2017 at 10:18:14AM +0100, Ricardo Silva wrote:
> Use the BIT(n) macro instead of '(1 << n)' in definitions where the bit
> semantics clearly applies.
> 
> Fixes true positive "Prefer using the BIT macro" checks reported by
> checkpatch.
> 
> Some of these checks are still triggering on definitions using
> '(1 << n)', namely for PIO2_CNTR_SC_DEV1, PIO2_CNTR_RW_LSB and
> PIO2_CNTR_MODE1. Leave them be, as the context there is more of a
> "multi-bit field value" ((val << n), where for some cases 'val' happens
> to be 1) rather than a "single bit" (1 << n), so keeping the value as is
> in the code makes it more readable that using a combination of BIT
> macros.
> 
> Signed-off-by: Ricardo Silva <rjpdasilva@xxxxxxxxx>

Acked-by: Martyn Welch <martyn@xxxxxxxxxxxx>

> ---
>  drivers/staging/vme/devices/vme_pio2.h | 80 +++++++++++++++++-----------------
>  1 file changed, 40 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/staging/vme/devices/vme_pio2.h b/drivers/staging/vme/devices/vme_pio2.h
> index 5577df3199e7..ac4a4bad4091 100644
> --- a/drivers/staging/vme/devices/vme_pio2.h
> +++ b/drivers/staging/vme/devices/vme_pio2.h
> @@ -68,38 +68,38 @@ static const int PIO2_CHANNEL_BANK[32] = { 0, 0, 0, 0, 0, 0, 0, 0,
>  					2, 2, 2, 2, 2, 2, 2, 2,
>  					3, 3, 3, 3, 3, 3, 3, 3 };
>  
> -#define PIO2_CHANNEL0_BIT		(1 << 0)
> -#define PIO2_CHANNEL1_BIT		(1 << 1)
> -#define PIO2_CHANNEL2_BIT		(1 << 2)
> -#define PIO2_CHANNEL3_BIT		(1 << 3)
> -#define PIO2_CHANNEL4_BIT		(1 << 4)
> -#define PIO2_CHANNEL5_BIT		(1 << 5)
> -#define PIO2_CHANNEL6_BIT		(1 << 6)
> -#define PIO2_CHANNEL7_BIT		(1 << 7)
> -#define PIO2_CHANNEL8_BIT		(1 << 0)
> -#define PIO2_CHANNEL9_BIT		(1 << 1)
> -#define PIO2_CHANNEL10_BIT		(1 << 2)
> -#define PIO2_CHANNEL11_BIT		(1 << 3)
> -#define PIO2_CHANNEL12_BIT		(1 << 4)
> -#define PIO2_CHANNEL13_BIT		(1 << 5)
> -#define PIO2_CHANNEL14_BIT		(1 << 6)
> -#define PIO2_CHANNEL15_BIT		(1 << 7)
> -#define PIO2_CHANNEL16_BIT		(1 << 0)
> -#define PIO2_CHANNEL17_BIT		(1 << 1)
> -#define PIO2_CHANNEL18_BIT		(1 << 2)
> -#define PIO2_CHANNEL19_BIT		(1 << 3)
> -#define PIO2_CHANNEL20_BIT		(1 << 4)
> -#define PIO2_CHANNEL21_BIT		(1 << 5)
> -#define PIO2_CHANNEL22_BIT		(1 << 6)
> -#define PIO2_CHANNEL23_BIT		(1 << 7)
> -#define PIO2_CHANNEL24_BIT		(1 << 0)
> -#define PIO2_CHANNEL25_BIT		(1 << 1)
> -#define PIO2_CHANNEL26_BIT		(1 << 2)
> -#define PIO2_CHANNEL27_BIT		(1 << 3)
> -#define PIO2_CHANNEL28_BIT		(1 << 4)
> -#define PIO2_CHANNEL29_BIT		(1 << 5)
> -#define PIO2_CHANNEL30_BIT		(1 << 6)
> -#define PIO2_CHANNEL31_BIT		(1 << 7)
> +#define PIO2_CHANNEL0_BIT		BIT(0)
> +#define PIO2_CHANNEL1_BIT		BIT(1)
> +#define PIO2_CHANNEL2_BIT		BIT(2)
> +#define PIO2_CHANNEL3_BIT		BIT(3)
> +#define PIO2_CHANNEL4_BIT		BIT(4)
> +#define PIO2_CHANNEL5_BIT		BIT(5)
> +#define PIO2_CHANNEL6_BIT		BIT(6)
> +#define PIO2_CHANNEL7_BIT		BIT(7)
> +#define PIO2_CHANNEL8_BIT		BIT(0)
> +#define PIO2_CHANNEL9_BIT		BIT(1)
> +#define PIO2_CHANNEL10_BIT		BIT(2)
> +#define PIO2_CHANNEL11_BIT		BIT(3)
> +#define PIO2_CHANNEL12_BIT		BIT(4)
> +#define PIO2_CHANNEL13_BIT		BIT(5)
> +#define PIO2_CHANNEL14_BIT		BIT(6)
> +#define PIO2_CHANNEL15_BIT		BIT(7)
> +#define PIO2_CHANNEL16_BIT		BIT(0)
> +#define PIO2_CHANNEL17_BIT		BIT(1)
> +#define PIO2_CHANNEL18_BIT		BIT(2)
> +#define PIO2_CHANNEL19_BIT		BIT(3)
> +#define PIO2_CHANNEL20_BIT		BIT(4)
> +#define PIO2_CHANNEL21_BIT		BIT(5)
> +#define PIO2_CHANNEL22_BIT		BIT(6)
> +#define PIO2_CHANNEL23_BIT		BIT(7)
> +#define PIO2_CHANNEL24_BIT		BIT(0)
> +#define PIO2_CHANNEL25_BIT		BIT(1)
> +#define PIO2_CHANNEL26_BIT		BIT(2)
> +#define PIO2_CHANNEL27_BIT		BIT(3)
> +#define PIO2_CHANNEL28_BIT		BIT(4)
> +#define PIO2_CHANNEL29_BIT		BIT(5)
> +#define PIO2_CHANNEL30_BIT		BIT(6)
> +#define PIO2_CHANNEL31_BIT		BIT(7)
>  
>  static const int PIO2_CHANNEL_BIT[32] = { PIO2_CHANNEL0_BIT, PIO2_CHANNEL1_BIT,
>  					PIO2_CHANNEL2_BIT, PIO2_CHANNEL3_BIT,
> @@ -120,12 +120,12 @@ static const int PIO2_CHANNEL_BIT[32] = { PIO2_CHANNEL0_BIT, PIO2_CHANNEL1_BIT,
>  					};
>  
>  /* PIO2_REGS_INT_STAT_CNTR (0xc) */
> -#define PIO2_COUNTER0			(1 << 0)
> -#define PIO2_COUNTER1			(1 << 1)
> -#define PIO2_COUNTER2			(1 << 2)
> -#define PIO2_COUNTER3			(1 << 3)
> -#define PIO2_COUNTER4			(1 << 4)
> -#define PIO2_COUNTER5			(1 << 5)
> +#define PIO2_COUNTER0			BIT(0)
> +#define PIO2_COUNTER1			BIT(1)
> +#define PIO2_COUNTER2			BIT(2)
> +#define PIO2_COUNTER3			BIT(3)
> +#define PIO2_COUNTER4			BIT(4)
> +#define PIO2_COUNTER5			BIT(5)
>  
>  static const int PIO2_COUNTER[6] = { PIO2_COUNTER0, PIO2_COUNTER1,
>  					PIO2_COUNTER2, PIO2_COUNTER3,
> @@ -133,8 +133,8 @@ static const int PIO2_COUNTER[6] = { PIO2_COUNTER0, PIO2_COUNTER1,
>  
>  /* PIO2_REGS_CTRL (0x18) */
>  #define PIO2_VME_INT_MASK		0x7
> -#define PIO2_LED			(1 << 6)
> -#define PIO2_LOOP			(1 << 7)
> +#define PIO2_LED			BIT(6)
> +#define PIO2_LOOP			BIT(7)
>  
>  /* PIO2_REGS_VME_VECTOR (0x19) */
>  #define PIO2_VME_VECTOR_SPUR		0x0
> -- 
> 2.12.2
> 
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux