From patchwork Sat Mar 22 14:33:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3877621 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2DB3DBF540 for ; Sat, 22 Mar 2014 14:33:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66AF020200 for ; Sat, 22 Mar 2014 14:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82149202BE for ; Sat, 22 Mar 2014 14:33:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750932AbaCVOdf (ORCPT ); Sat, 22 Mar 2014 10:33:35 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:43442 "EHLO mail-pd0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899AbaCVOde (ORCPT ); Sat, 22 Mar 2014 10:33:34 -0400 Received: by mail-pd0-f172.google.com with SMTP id p10so3530442pdj.3 for ; Sat, 22 Mar 2014 07:33:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:content-type :mime-version:content-transfer-encoding; bh=Akgg6erFnuPPmBphXAAVRkAabbrDsozFCWoTM5fA424=; b=ZQcQrt58XyCG0cOVFZb6rjgz06cTwjjb0JlckruASKrX5hPJQisGZ4cxD65zTvKmtB ibxajfu3bvLcmpDpfTpaTqYsDNOho67tePtRTlNbBl0Yev3kWiIqfcNOXkeTx8+hgKHW JqbBPV9AXns6woOI3jEbmPJ/MVwMzFhVW64S+92BWgnag8+cs1b+sg40qcGd14v+sdmW MQ2U+jUP0ajixB1JAg3Tls3EV75sng4MiUIKgeAjB4Ok7jr48SSk5R3qkEIYNXBLLE9/ UNXE9HtNsBbHor/ASX9pGHdFlnXZouX4F4LaB3I58QQF8s5NwRtsK91zARf2k1DJjhV0 mYXg== X-Gm-Message-State: ALoCoQnMV7chsZHZQe//lpuPAAcZ7F8e9qkL6IgJgU4Dt6246A0pSrZrtfpLn9/S03G3XdYj7qZm X-Received: by 10.68.233.37 with SMTP id tt5mr2889687pbc.154.1395498813952; Sat, 22 Mar 2014 07:33:33 -0700 (PDT) Received: from [192.168.0.102] (218-164-100-135.dynamic.hinet.net. [218.164.100.135]) by mx.google.com with ESMTPSA id xi5sm43027928pab.27.2014.03.22.07.33.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 22 Mar 2014 07:33:32 -0700 (PDT) Message-ID: <1395498809.16958.1.camel@phoenix> Subject: [PATCH] spi: atmel: Fix test unsigned var < 0 From: Axel Lin To: Mark Brown Cc: Wenyou Yang , linux-spi@vger.kernel.org Date: Sat, 22 Mar 2014 22:33:29 +0800 X-Mailer: Evolution 3.8.4-0ubuntu1 Mime-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@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 current_remaining_bytes is an unsigned long and cannot be below 0. Signed-off-by: Axel Lin --- drivers/spi/spi-atmel.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index bda961e..3e8c4cc 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -873,13 +873,11 @@ atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer) } else { spi_readl(as, RDR); } - if (xfer->bits_per_word > 8) { + + if (xfer->bits_per_word > 8) as->current_remaining_bytes -= 2; - if (as->current_remaining_bytes < 0) - as->current_remaining_bytes = 0; - } else { + else as->current_remaining_bytes--; - } } /* Interrupt