From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aneesh V Date: Tue, 17 May 2011 14:14:17 +0530 Subject: [U-Boot] [PATCH v3 02/10] armv7: add miscellaneous utility macros In-Reply-To: <20110517052716.50A141491B08@gemini.denx.de> References: <1299589658-30896-1-git-send-email-aneesh@ti.com> <1305202276-27784-3-git-send-email-aneesh@ti.com> <20110515184421.D7AB91491B06@gemini.denx.de> <20110516055102.2E15B1491B07@gemini.denx.de> <20110517052716.50A141491B08@gemini.denx.de> Message-ID: <4DD23561.70105@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 Hi Wolfgang, On Tuesday 17 May 2011 10:57 AM, Wolfgang Denk wrote: > Dear Simon Glass, > > In message you wrote: >> >> There are a few very primitive macros in setbits and clrbits. I would >> very much like to see at least: > > Maybe we can agree to use these existing macros then instead of > inventing new ones with the same functionality. > >> - define a field once in a header in an easy format along with any >> enums which define allowable values if applicable >> - pack and unpack a value into a field: so set a bitfield to 13, for exampl= >> e >> - obtain a mask for a field (i.e. with all bits set) >> - equivalent of writel and readl for a bitfield (writel in fact being >> read/modify/write so perhaps a different name) >> >> Some of these exist, some don't. > > Do you know of examples of such more complex definitions in the Linux > kernel code? > In fact I had searched for a macro for similar needs as my set_bit_field() is addressing in Linux Kernel too but didn't find any. Please note that my requirement is not for doing IO but doing bit field operations on a C integer variable: 1. Prepare a variable field by field to be finally written to a register using writel() 2. Extract a field from a variable that typically holds the value of a register after a readl() I couldn't find any utility macros/functions for doing something like this. Please somebody correct me if I am wrong. best regards, Aneesh