From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aneesh V Date: Tue, 21 Jun 2011 12:35:55 +0530 Subject: [U-Boot] [PATCH v2 13/22] omap4: add clock support In-Reply-To: <20110621070530.7C86512B7B83@gemini.denx.de> References: <1298893591-17636-1-git-send-email-aneesh@ti.com> <1305472900-4004-14-git-send-email-aneesh@ti.com> <4E0030F8.6030104@ti.com> <20110621070530.7C86512B7B83@gemini.denx.de> Message-ID: <4E0042D3.6090102@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 Tuesday 21 June 2011 12:35 PM, Wolfgang Denk wrote: > Dear Aneesh V, > > In message<4E0030F8.6030104@ti.com> you wrote: >> >> I am finding it difficult to implement this using the struct based >> approach. I tried the sample code below: >> >> struct my_regs_struct { >> const unsigned int reg1; >> const unsigned int reg2; >> const unsigned int reg3; >> }; >> The const for structure fields above were not intended. I put them while debugging this issue and forgot to remove later. >> static struct my_regs_struct *const my_regs = (struct my_regs_struct >> *)0x1000; >> >> static unsigned int *const reg_arr[] = { >> &my_regs->reg1, >> &my_regs->reg3 >> }; >> >> void main(void) >> { >> printf("regs %x %x \n", reg_arr[0], reg_arr[1]); >> } > > Sorry, but I fail to understand the problem. Why is reg_arr[] needed? > Why don't you use > > struct my_regs_struct { > const unsigned int reg[3]; > }; > ? I want a number of register addresses in an array - an array of constant pointers. The array is populated at compile time with the addresses of all the modules that need to be initialized. At run-time I do a specific operation on all the registers given in this array. best regards, Aneesh