From: Wolfgang Denk Date: Wed, 12 Jul 2017 14:52:51 +0200 Subject: [U-Boot] [PATCH 01/14] powerpc, 8xx: Simplify brgclk calculation and remove get_brgclk() In-Reply-To: <59ac182501e89d3b9ee1dc7c31ce358ff33c0877.1499629706.git.christophe.leroy@c-s.fr> References: <59ac182501e89d3b9ee1dc7c31ce358ff33c0877.1499629706.git.christophe.leroy@c-s.fr> Message-ID: <20170712125251.4371A120202@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Christophe, In message <59ac182501e89d3b9ee1dc7c31ce358ff33c0877.1499629706.git.christophe.leroy@c-s.fr> you wrote: > divider is calculated based on SCCR_DFBRG, with: > SCCR_DFBRG 00 => divider 1 = 1 << 0 > SCCR_DFBRG 01 => divider 4 = 1 << 2 > SCCR_DFBRG 10 => divider 16 = 1 << 4 > SCCR_DFBRG 11 => divider 64 = 1 << 6 > > This can be easily converted to a single shift operation: > divider = 1 << (SCCR_DFBRG * 2) Agreed, but... > - switch ((sccr & SCCR_DFBRG11) >> 11) { ... > + uint divider = 1 << ((sccr & SCCR_DFBRG11) >> 10); The code would be easier to read / understand if you made the calculation obvious, i. e. uint divider = 1 << (((sccr & SCCR_DFBRG11) >> 11) * 2); The compiler generates the same code, so there is no size effect. Reviewed-by: Wolfgang Denk Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. - Wernher von Braun