From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753730AbZISVkh (ORCPT ); Sat, 19 Sep 2009 17:40:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753821AbZISVk1 (ORCPT ); Sat, 19 Sep 2009 17:40:27 -0400 Received: from kroah.org ([198.145.64.141]:40435 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753665AbZISVkX (ORCPT ); Sat, 19 Sep 2009 17:40:23 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Anton Vorontsov , Alan Cox , Greg Kroah-Hartman Subject: [PATCH 28/79] 8250: Now honours baud rate lower bounds Date: Sat, 19 Sep 2009 14:36:33 -0700 Message-Id: <1253396244-7885-28-git-send-email-gregkh@suse.de> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <20090919213345.GB7668@kroah.com> References: <20090919213345.GB7668@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anton Vorontsov A platform clock drives 8250 ports in most SOC systems, the clock might run at high frequencies, and so it's not always possible to downscale uart clock to a desired value. Currently the 8250 uart driver accepts not supported baud rates, and what is worse, it is doing this silently, and then passes not accepted values to a new termios, so userspace has no chance to catch this kind of errors (userspace verifies that settings were accepted by reading back and comparing the settings). This patch fixes the issue by passing minimum baud rate to the uart_get_baud_rate() call, the call should take care of all bounds, so userspace should now report: # stty -F /dev/ttyS0 speed 300 115200 stty: /dev/ttyS0: unable to perform all requested operations p.s. uart_get_baud_rate() falls back to 9600, which still might be too low for some 10 GHz platforms, but that's a separate issue, and we can wait with fixing this till we find such a platform. Signed-off-by: Anton Vorontsov Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/serial/8250.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 83168a6..1fd4894 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c @@ -2272,7 +2272,9 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios, /* * Ask the core to calculate the divisor for us. */ - baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); + baud = uart_get_baud_rate(port, termios, old, + port->uartclk / 16 / 0xffff, + port->uartclk / 16); quot = serial8250_get_divisor(port, baud); /* -- 1.6.4.2