From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 3 Nov 2011 17:56:49 +0100 Subject: [U-Boot] [PATCH 3/4 V2] OneNAND: Add simple OneNAND SPL In-Reply-To: <4EB2BF10.8040607@freescale.com> References: <1320067393-18822-4-git-send-email-marek.vasut@gmail.com> <201111030115.35835.marek.vasut@gmail.com> <4EB2BF10.8040607@freescale.com> Message-ID: <201111031756.49790.marek.vasut@gmail.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. Expensive in what way? Either way, I don't think this matters that much.