From patchwork Sat Sep 21 07:43:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Pelykh X-Patchwork-Id: 2922051 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7DCA89F1E2 for ; Sat, 21 Sep 2013 07:44:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB63820513 for ; Sat, 21 Sep 2013 07:44:27 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4B5B2050E for ; Sat, 21 Sep 2013 07:44:26 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNHrX-0006lS-RN; Sat, 21 Sep 2013 07:44:19 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNHrV-0003nj-DW; Sat, 21 Sep 2013 07:44:17 +0000 Received: from mail-wg0-x230.google.com ([2a00:1450:400c:c00::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VNHrS-0003mr-5c for linux-arm-kernel@lists.infradead.org; Sat, 21 Sep 2013 07:44:15 +0000 Received: by mail-wg0-f48.google.com with SMTP id n12so1342853wgh.27 for ; Sat, 21 Sep 2013 00:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=tACoaEXIJNllWZpEqdpT9A9/dMSF8k+crnXW/WMWzy8=; b=aP7PwwuDdgmoFmqL0+OyxLRtR+5motb1xpzdrZajN1WkjycBrvOLUGqqTXsn6/razC omfAtNxfOLBJ475az50OC/+KQaXGU2h4t96euHq8cKlYdeyweNLIjh9EJFiq+hAbvfKT Knb42EJYzwXzKvBf8cGHFXDcSTaR/vzghUDHR0kzbteYIrNdhcOZbUvrJRD0w3lQXVmy rAw7LoMtk0I3VZC4YAI7/xgqD7HpvwdENQWAw4mM4yqGUeTH1DdiRng4nPb/LUz1VujH Wg6qjA1AF3TM/TGt9fpI/YXcIrIthn07B1HOeHek2IKxM67AS+NtTc3++Hz3bnZKRDQ5 TQHA== X-Received: by 10.194.5.35 with SMTP id p3mr10693wjp.47.1379749432061; Sat, 21 Sep 2013 00:43:52 -0700 (PDT) Received: from inertiallabs-linux64 (5353B86B.cm-6-4c.dynamic.ziggo.nl. [83.83.184.107]) by mx.google.com with ESMTPSA id e5sm9685997wiy.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 00:43:50 -0700 (PDT) Date: Sat, 21 Sep 2013 03:43:44 -0400 From: Alexey Pelykh To: Greg KH Subject: [PATCH] OMAP/serial: Fix division by zero exception on 3M+ baud rates Message-ID: <20130921074344.GA15524@inertiallabs-linux64> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130921_034414_343686_E9F61369 X-CRM114-Status: UNSURE ( 9.09 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) Cc: Tony Lindgren , linux-kernel@vger.kernel.org, Felipe Balbi , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alexey Pelykh Fixes issue with division-by-zero exception, that occurred when a baud rate higher than 3Mbaud was requested. Signed-off-by: Alexey Pelykh Cc: Tony Lindgren Cc: Felipe Balbi Cc: Greg KH Cc: linux-serial@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-omap@vger.kernel.org Cc: linux-kernel@vger.kernel.org diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 816d1a2..808a880 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -240,8 +240,8 @@ serial_omap_baud_is_mode16(struct uart_port *port, unsigned int baud) { unsigned int n13 = port->uartclk / (13 * baud); unsigned int n16 = port->uartclk / (16 * baud); - int baudAbsDiff13 = baud - (port->uartclk / (13 * n13)); - int baudAbsDiff16 = baud - (port->uartclk / (16 * n16)); + int baudAbsDiff13 = n13 ? (baud - (port->uartclk / (13 * n13))) : INT_MAX; + int baudAbsDiff16 = n16 ? (baud - (port->uartclk / (16 * n16))) : INT_MAX; if(baudAbsDiff13 < 0) baudAbsDiff13 = -baudAbsDiff13; if(baudAbsDiff16 < 0)