From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maxime Coquelin Subject: Re: [PATCH v3 10/15] serial: stm32-usart: Add STM32 USART Driver Date: Thu, 19 Mar 2015 18:35:30 +0100 Message-ID: References: <1426197361-19290-1-git-send-email-maxime.coquelin@st.com> <1426197361-19290-11-git-send-email-maxime.coquelin@st.com> <550AE41C.8070803@hurleysoftware.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <550AE41C.8070803-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Peter Hurley Cc: Andy Shevchenko , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , =?UTF-8?Q?Andreas_F=C3=A4rber?= , Geert Uytterhoeven , Rob Herring , Philipp Zabel , Linus Walleij , Arnd Bergmann , Stefan Agner , Peter Meerwald , Paul Bolle , Jonathan Corbet , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Russell King , Daniel Lezcano , Thomas Gleixner , Greg Kroah-Hartman , Jiri Slaby , Andrew Morton List-Id: linux-gpio@vger.kernel.org 2015-03-19 15:58 GMT+01:00 Peter Hurley : > On 03/19/2015 09:55 AM, Maxime Coquelin wrote: >>>>>> +static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, >>>>>> + struct ktermios *old) > [...] >>>>>> + usardiv = (port->uartclk * 25) / (baud * 4); >>>>>> + mantissa = (usardiv / 100) << USART_BRR_DIV_M_SHIFT; >>>>>> + fraction = DIV_ROUND_CLOSEST((usardiv % 100) * 16, 100); >>>>>> + if (fraction & ~USART_BRR_DIV_F_MASK) { >>>>>> + fraction = 0; >>>>>> + mantissa += (1 << USART_BRR_DIV_M_SHIFT); >>>>>> + } > [...] >> Really, I would prefer keeping this fractional divider as it is >> implemented today. > > You have to admit that's basically an unintelligible mess; > how would anyone ever be able to refactor and replace that with a > common divider implementation? > > At the very least, please comment on the formula and format. Ok, I will refactor the implementation, and comment it. Regards, Maxime > > Regards, > Peter Hurley -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html