From patchwork Wed May 20 18:06:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6448281 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66ECE9F444 for ; Wed, 20 May 2015 18:06:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C9E820351 for ; Wed, 20 May 2015 18:06:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99A6A20364 for ; Wed, 20 May 2015 18:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754133AbbETSGU (ORCPT ); Wed, 20 May 2015 14:06:20 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:37238 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753571AbbETSGS (ORCPT ); Wed, 20 May 2015 14:06:18 -0400 Received: from ayla.of.borg ([84.193.93.87]) by baptiste.telenet-ops.be with bizsmtp id WJ6G1q00c1t5w8s01J6GbS; Wed, 20 May 2015 20:06:17 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1Yv8Nk-0006Ue-MT; Wed, 20 May 2015 20:06:16 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1Yv8Np-000310-2Q; Wed, 20 May 2015 20:06:21 +0200 From: Geert Uytterhoeven To: Magnus Damm , Laurent Pinchart , Nobuhiro Iwamatsu , Yoshihiro Kaneko , Wolfram Sang , Guennadi Liakhovetski Cc: linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/8] serial: sh-sci: Use min_t()/max_t() instead of casts Date: Wed, 20 May 2015 20:06:09 +0200 Message-Id: <1432145174-11534-4-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432145174-11534-1-git-send-email-geert+renesas@glider.be> References: <1432145174-11534-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 When comparing differently sized types, it's better to use min_t()/max_t() than adding casts. Also use "unsigned int" instead of "int", as that's the right type for the length of an SG entry. Signed-off-by: Geert Uytterhoeven Acked-by: Laurent Pinchart --- drivers/tty/serial/sh-sci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 0aec66cf68615972..21c07c6cb0cd2220 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1520,7 +1520,8 @@ static void work_fn_tx(struct work_struct *work) sg->offset = xmit->tail & (UART_XMIT_SIZE - 1); sg_dma_address(sg) = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) + sg->offset; - sg_dma_len(sg) = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE), + sg_dma_len(sg) = min_t(unsigned int, + CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE), CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE)); spin_unlock_irq(&port->lock); @@ -1746,7 +1747,7 @@ static void sci_request_dma(struct uart_port *port) s->chan_rx = chan; - s->buf_len_rx = 2 * max(16, (int)port->fifosize); + s->buf_len_rx = 2 * max_t(size_t, 16, port->fifosize); buf[0] = dma_alloc_coherent(chan->device->dev, s->buf_len_rx * 2, &dma[0], GFP_KERNEL);