From: Ian Abbott <abbotti@mev.co.uk>
To: Ravishankar Karkala Mallikarjunayya <ravishankarkm32@gmail.com>,
hsweeten@visionengravers.com, gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/10] Staging: comedi: fix BIT macro issue in das6402.c
Date: Wed, 1 Jun 2016 14:58:58 +0100 [thread overview]
Message-ID: <574EEA22.2050209@mev.co.uk> (raw)
In-Reply-To: <1464776813-31659-7-git-send-email-ravishankarkm32@gmail.com>
On 01/06/16 11:26, Ravishankar Karkala Mallikarjunayya wrote:
> This patch Replace all occurences of (1<<x) by BIT(x) in the file das6402.c
> to get rid of checkpatch.pl "CHECK" output "Prefer using the BIT macro"
>
> Signed-off-by: Ravishankar Karkala Mallikarjunayya <ravishankarkm32@gmail.com>
> ---
> drivers/staging/comedi/drivers/das6402.c | 56 ++++++++++++++++----------------
> 1 file changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c
> index 1701294..f6319b3 100644
> --- a/drivers/staging/comedi/drivers/das6402.c
> +++ b/drivers/staging/comedi/drivers/das6402.c
[snip]
> #define DAS6402_CTRL_REG 0x09
> #define DAS6402_CTRL_SOFT_TRIG (0 << 0)
> -#define DAS6402_CTRL_EXT_FALL_TRIG (1 << 0)
> +#define DAS6402_CTRL_EXT_FALL_TRIG BIT(0)
> #define DAS6402_CTRL_EXT_RISE_TRIG (2 << 0)
> #define DAS6402_CTRL_PACER_TRIG (3 << 0)
In cases like this, where there are several values defined for a
multi-bit field, all shifted by the same amount, the 'BIT(x)' usage
makes the code more unreadable. The DAS6402_CTRL_SOFT_TRIG,
DAS6402_CTRL_EXT_FALL_TRIG, DAS6402_CTRL_EXT_RISE_TRIG, and
DAS6402_CTRL_PACER_TRIG values should all share the same style, perhaps
something like this:
#define DAS6402_CTRL_TRIG(x) ((x) << 0)
#define DAS6402_CTRL_SOFT_TRIG DAS6402_CTRL_TRIG(0)
#define DAS6402_CTRL_EXT_FALL_TRIG DAS6402_CTRL_TRIG(1)
#define DAS6402_CTRL_EXT_RISE_TRIG DAS6402_CTRL_TRIG(2)
#define DAS6402_CTRL_PACER_TRIG DAS6402_CTRL_TRIG(3)
[snip]
> #define DAS6402_MODE_REG 0x0b
> #define DAS6402_MODE_RANGE(x) ((x) << 0)
> #define DAS6402_MODE_POLLED (0 << 2)
> -#define DAS6402_MODE_FIFONEPTY (1 << 2)
> +#define DAS6402_MODE_FIFONEPTY BIT(2)
> #define DAS6402_MODE_FIFOHFULL (2 << 2)
> #define DAS6402_MODE_EOB (3 << 2)
Similarly, DAS6402_MODE_POLLED, DAS6402_MODE_FIFONEPTY,
DAS6402_MODE_FIFOHFULL, and DAS6402_MODE_EOB are all values for the same
multi-bit field, and should be defined in the same style, perhaps
something like this:
#define DAS6402_MODE_BUF(x) ((x) << 2)
#define DAS6402_MODE_BUF_POLLED DAS6402_MODE_BUF(0)
#define DAS6402_MODE_FIFONEPTY DAS6402_MODE_BUF(1)
#define DAS6402_MODE_FIFOHFULL DAS6402_MODE_BUF(2)
#define DAS6402_MODE_EOB DAS6402_MODE_BUF(3)
> -#define DAS6402_MODE_ENHANCED (1 << 4)
> -#define DAS6402_MODE_SE (1 << 5)
> -#define DAS6402_MODE_UNI (1 << 6)
> +#define DAS6402_MODE_ENHANCED BIT(4)
> +#define DAS6402_MODE_SE BIT(5)
> +#define DAS6402_MODE_UNI BIT(6)
> #define DAS6402_MODE_DMA1 (0 << 7)
> -#define DAS6402_MODE_DMA3 (1 << 7)
> +#define DAS6402_MODE_DMA3 BIT(7)
Similarly, DAS6402_MODE_DMA1 and DAS6402_MODE_DMA3 should be defined in
the same style, perhaps something like this:
#define DAS6402_MODE_DMA(x) ((x) << 7)
#define DAS6402_MODE_DMA1 DAS6402_MODE_DMA(0)
#define DAS6402_MODE_DMA3 DAS6402_MODE_DMA(1)
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
next prev parent reply other threads:[~2016-06-01 13:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 10:26 [PATCH 01/10] Staging: comedi: Use unsigned int instead of unsigned issue in pcmuio.c Ravishankar Karkala Mallikarjunayya
2016-06-01 10:26 ` [PATCH 02/10] Staging: comedi: fix bare use of unsigned issue in ni_65xx.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:26 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 03/10] Staging: comedi: Indentation issue in mpc624.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:27 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 04/10] Staging: comedi:Fix a warning issues in me_daq.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:28 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 05/10] Staging: comedi: Fix comment issues in jr3_pci.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:29 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 06/10] Staging: comedi: Prefer using the BIT macro issue in das16.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:30 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 07/10] Staging: comedi: fix BIT macro issue in das6402.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:58 ` Ian Abbott [this message]
2016-06-01 10:26 ` [PATCH 08/10] Staging: comedi: Used unsigned int instead of unsigned issue in jr3_pci.c Ravishankar Karkala Mallikarjunayya
2016-06-01 13:59 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 09/10] Staging: comedi: Block comment issue fixed for das16m1.c Ravishankar Karkala Mallikarjunayya
2016-06-01 14:01 ` Ian Abbott
2016-06-01 10:26 ` [PATCH 10/10] Staging: comedi: Preferd unsigned int instead of unsigned in comedi_bond.c Ravishankar Karkala Mallikarjunayya
2016-06-01 14:03 ` Ian Abbott
2016-06-01 13:25 ` [PATCH 01/10] Staging: comedi: Use unsigned int instead of unsigned issue in pcmuio.c Ian Abbott
2016-06-08 10:09 ` Ian Abbott
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=574EEA22.2050209@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=hsweeten@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ravishankarkm32@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox