lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Nov 2015 16:45:21 +0000
From:	Hartley Sweeten <HartleyS@...ionengravers.com>
To:	Ian Abbott <abbotti@....co.uk>,
	Ranjith Thangavel <ranjithece24@...il.com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC:	"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro

On Wednesday, November 18, 2015 9:42 AM, Ian Abbott wrote:
> On 16/11/15 17:18, Ranjith Thangavel wrote:
 [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.)

It would be more appropriate as a macro:

#define DMM32AT_AI_CFG_SCINT(x)		(((x) & 0x3) << 4)
#define DMM32AT_AI_CFG_SCINT_20US	DMM32AT_AI_CFG_SCINT (0)
#define DMM32AT_AI_CFG_SCINT_15US	DMM32AT_AI_CFG_SCINT (1)
#define DMM32AT_AI_CFG_SCINT_10US	DMM32AT_AI_CFG_SCINT (2)
#define DMM32AT_AI_CFG_SCINT_5US	DMM32AT_AI_CFG_SCINT (3)

Regards,
Hartley

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ