From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Thu, 3 Nov 2011 12:06:52 -0500 Subject: [U-Boot] [PATCH 3/4 V2] OneNAND: Add simple OneNAND SPL In-Reply-To: <201111031756.49790.marek.vasut@gmail.com> References: <1320067393-18822-4-git-send-email-marek.vasut@gmail.com> <201111030115.35835.marek.vasut@gmail.com> <4EB2BF10.8040607@freescale.com> <201111031756.49790.marek.vasut@gmail.com> Message-ID: <4EB2CA2C.5070109@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/03/2011 11:56 AM, Marek Vasut wrote: >> 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? Compare the resulting asm code. You're replacing this: a = (b + 4095) >> 12; with this: a = b >> 12; if (b & 4095) a++; > Either way, I don't think this matters that much. This is code that has to fit in 1K -- why waste instructions by writing code in a way that is *less* readable? -Scott