Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756396AbbKRRCy (ORCPT ); Wed, 18 Nov 2015 12:02:54 -0500 Received: from smtp89.iad3a.emailsrvr.com ([173.203.187.89]:40220 "EHLO smtp89.iad3a.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751843AbbKRRCx (ORCPT ); Wed, 18 Nov 2015 12:02:53 -0500 X-Auth-ID: abbotti@mev.co.uk X-Sender-Id: abbotti@mev.co.uk Subject: Re: [PATCH 1/2] comedi: dmm32at: Fix coding style - use BIT macro To: Hartley Sweeten , Ranjith Thangavel , "gregkh@linuxfoundation.org" References: <1447694308-7724-1-git-send-email-ranjithece24@gmail.com> <564CAA56.2030301@mev.co.uk> Cc: "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" From: Ian Abbott Message-ID: <564CAF3A.20507@mev.co.uk> Date: Wed, 18 Nov 2015 17:02:50 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1836 Lines: 45 On 18/11/15 16:45, Hartley Sweeten wrote: > 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) Yes, but without the spaces in the macro calls! It's slightly surprising no one has pushed a generic macro for this sort of thing, maybe something like: #define MBIT(v, s) ((v) * BIT(s)) although the name sucks - maybe the problem is thinking up a decent name! -- -=( Ian Abbott @ MEV Ltd. E-mail: )=- -=( 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/