Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1272376

Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro

From Ian Abbott <abbotti@mev.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro
Date 2015-11-18 17:50 +0100
Message-ID <qwe5H-5ul-11@gated-at.bofh.it> (permalink)
References <qvvBE-1Ii-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 16/11/15 17:18, Ranjith Thangavel wrote:
> BIT macro is used for defining BIT location instead of
> shifting operator, usleep_range is preferred over
> udelay - coding style issue

This patch doesn't use usleep_range(), so the description is inaccurate.

>
> Signed-off-by: Ranjith Thangavel <ranjithece24@gmail.com>
> ---
>   drivers/staging/comedi/drivers/dmm32at.c |  100 +++++++++++++++---------------
>   1 file changed, 50 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
> index 958c0d4..d312fda 100644
> --- a/drivers/staging/comedi/drivers/dmm32at.c
> +++ b/drivers/staging/comedi/drivers/dmm32at.c
[snip]
> -#define DMM32AT_AI_CFG_SCINT_20US	(0 << 4)
> -#define DMM32AT_AI_CFG_SCINT_15US	(1 << 4)
> -#define DMM32AT_AI_CFG_SCINT_10US	(2 << 4)
> -#define DMM32AT_AI_CFG_SCINT_5US	(3 << 4)
> -#define DMM32AT_AI_CFG_RANGE		(1 << 3)  /* 0=5V  1=10V */
> -#define DMM32AT_AI_CFG_ADBU		(1 << 2)  /* 0=bipolar  1=unipolar */
> +#define DMM32AT_AI_CFG_SCINT_20US	0
> +#define DMM32AT_AI_CFG_SCINT_15US	BIT(4)
> +#define DMM32AT_AI_CFG_SCINT_10US	(BIT(5) & ~BIT(4))

The `(BIT(5) & ~BIT(4))` is a bit ugly.  You can just use `BIT(5)` to 
fit in with the style of your other changes.

(Personally though, I don't think BIT() is appropriate for shifted, 
multi-bit values.)

> +#define DMM32AT_AI_CFG_SCINT_5US	(BIT(5) | BIT(4))
> +#define DMM32AT_AI_CFG_RANGE		BIT(3)  /* 0=5V  1=10V */
> +#define DMM32AT_AI_CFG_ADBU		BIT(2)  /* 0=bipolar  1=unipolar */
[snip]

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro Ranjith Thangavel <ranjithece24@gmail.com> - 2015-11-16 18:20 +0100
  [PATCH 2/2] comedi: dmm32at: Fix coding style - use BIT macro Ranjith Thangavel <ranjithece24@gmail.com> - 2015-11-16 18:20 +0100
    Re: [PATCH 2/2] comedi: dmm32at: Fix coding style - use BIT macro Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-17 17:30 +0100
  Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-17 17:30 +0100
  Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 17:50 +0100
    RE: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro Hartley Sweeten <HartleyS@visionengravers.com> - 2015-11-18 18:10 +0100
      Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro Ian Abbott <abbotti@mev.co.uk> - 2015-11-18 18:10 +0100

csiph-web