From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Hurley Subject: Re: [PATCH v3 10/15] serial: stm32-usart: Add STM32 USART Driver Date: Thu, 19 Mar 2015 10:58:36 -0400 Message-ID: <550AE41C.8070803@hurleysoftware.com> References: <1426197361-19290-1-git-send-email-maxime.coquelin@st.com> <1426197361-19290-11-git-send-email-maxime.coquelin@st.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Maxime Coquelin , Andy Shevchenko Cc: =?UTF-8?B?VXdlIEtsZWluZS1Lw7ZuaWc=?= , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , 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 , "David S. Miller" List-Id: linux-arch.vger.kernel.org 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. 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-f43.google.com ([209.85.192.43]:36857 "EHLO mail-qg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755931AbbCSO6n (ORCPT ); Thu, 19 Mar 2015 10:58:43 -0400 Received: by qgf3 with SMTP id 3so67097516qgf.3 for ; Thu, 19 Mar 2015 07:58:41 -0700 (PDT) Message-ID: <550AE41C.8070803@hurleysoftware.com> Date: Thu, 19 Mar 2015 10:58:36 -0400 From: Peter Hurley MIME-Version: 1.0 Subject: Re: [PATCH v3 10/15] serial: stm32-usart: Add STM32 USART Driver References: <1426197361-19290-1-git-send-email-maxime.coquelin@st.com> <1426197361-19290-11-git-send-email-maxime.coquelin@st.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Maxime Coquelin , Andy Shevchenko Cc: =?UTF-8?B?VXdlIEtsZWluZS1Lw7ZuaWc=?= , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , 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 , "David S. Miller" , Mauro Carvalho Chehab , Joe Perches , Antti Palosaari , Tejun Heo , Will Deacon , Nikolay Borisov , Rusty Russell , Kees Cook , Michal Marek , Linux Documentation List , linux-arm Mailing List , "linux-kernel@vger.kernel.org" , devicetree , "linux-gpio@vger.kernel.org" , "linux-serial@vger.kernel.org" , Linux-Arch , "linux-api@vger.kernel.org" Message-ID: <20150319145836.WCKhgucXRw1EjQoDtyhIESCHUmAdscjwH7SPBn1DM_s@z> 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. Regards, Peter Hurley