From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aneesh V Date: Wed, 12 Jan 2011 14:38:01 +0530 Subject: [U-Boot] [PATCH 2/8] armv7: cache maintenance operations for armv7 In-Reply-To: <4D286F58.9010605@free.fr> References: <1293018898-13253-1-git-send-email-aneesh@ti.com> <1293018898-13253-3-git-send-email-aneesh@ti.com> <4D2805FC.7070200@free.fr> <4D2863D0.2050005@ti.com> <4D286F58.9010605@free.fr> Message-ID: <4D2D6F71.1020906@ti.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Saturday 08 January 2011 07:36 PM, Albert ARIBAUD wrote: > Le 08/01/2011 14:17, Aneesh V a ?crit : > >>>> +/* some utility macros */ >>>> +#define mask(start, end) \ >>>> + (((1<< ((end) - (start) + 1)) - 1)<< (start)) >>>> + >>>> +#define mask_n_get(reg, start, end) \ >>>> + (((reg)& mask(start, end))>> (start)) >>> >>> Seeing as these functions are only used in the ARMv7 cache C file, they >>> should be moved there. >> >> I plan to use a modified version of mask_n_get() and its set couterpart >> mask_n_set() in my subsequent works in more files. >> >> Can I keep it here itself or should I move it to an OMAP specific >> header file or can I move it to a more generic header file? Please >> suggest. > > They're very generic actually. I think they should go to a gereric bit > manipulation header, and be named a... bit... more explicitly. For > instance, the name 'mask' does not show that the macro creates a range > of 'one' bits from start to end. > What I need is something like below: #define get_bit_field(nr, start, mask)\ (((nr) & (mask)) >> (start)) #define set_bit_field(nr, start, mask, val)\ (nr) = ((nr) & ~(mask)) | (((val) << (start)) & (mask)) Can these go in a generic header? If so, can I add them to "include/linux/bitops.h" Best regards, Aneesh