From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Thu, 3 Nov 2011 11:19:28 -0500 Subject: [U-Boot] [PATCH 3/4 V2] OneNAND: Add simple OneNAND SPL In-Reply-To: <201111030115.35835.marek.vasut@gmail.com> References: <1320067393-18822-4-git-send-email-marek.vasut@gmail.com> <1320188059-6612-1-git-send-email-marek.vasut@gmail.com> <4EB1C737.20702@freescale.com> <201111030115.35835.marek.vasut@gmail.com> Message-ID: <4EB2BF10.8040607@freescale.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 11/02/2011 07:15 PM, Marek Vasut wrote: >> On 11/01/2011 05:54 PM, Marek Vasut wrote: >>> +static void spl_onenand_get_geometry(struct spl_onenand_data *data) >>> +{ > [...] > >>> + /* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ >>> + if (data.pagesize == 2048) { >>> + total_pages = len / 2048; >>> + page = offset / 2048; >>> + total_pages += !!(len & 2047); >>> + } else if (data.pagesize == 4096) { >>> + total_pages = len / 4096; >>> + page = offset / 4096; >>> + total_pages += !!(len & 4095); >>> + } >> >> What's wrong with DIV_ROUND_UP? It should produce smaller code than >> what you've done here... > > It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand. It shouldn't do that if the divisor is a constant power of 2. The compiler will turn it into a shift, just like with the other divides in the above code fragment. You can't use DIV_ROUND_UP directly on data.pagesize, but you can use it in each branch of the if statement instead of that awkward and slightly more expensive !!(len & 4095) construct. -Scott