From patchwork Thu Mar 27 01:26:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 3896081 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 BDA84BF540 for ; Thu, 27 Mar 2014 01:26:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE15620218 for ; Thu, 27 Mar 2014 01:26:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B47E2021F for ; Thu, 27 Mar 2014 01:26:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbaC0B0n (ORCPT ); Wed, 26 Mar 2014 21:26:43 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:62569 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194AbaC0B0m (ORCPT ); Wed, 26 Mar 2014 21:26:42 -0400 Received: by mail-pb0-f52.google.com with SMTP id rr13so2733569pbb.39 for ; Wed, 26 Mar 2014 18:26:42 -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=ZNxUB+Pea1Pc2GUxmq262f06j3nJj39sWCVhwNDiqC8=; b=WV8YG2cUiLU62LAdonAMtZL3L1xe8S55Hz+akB1oqHD6aXO5PlFsH+t6k3QK3clrP1 OKzLY69dVzI6H4LhtxjpK33a3cLEHMqZ1YXS5oJSAuDobCAA+I2McX3bek2hCdhp8vdT jwbvpfVhVkmFTi5De7eCcVNb90dvghtFtv2a6r2jKfZrPbj322BH6T8n/vrcoUBBEVvo BU/QgIjiK7vM6qHYTpKYGNDn5iLyPUOKeajHJ8+qnAZajPkcYwXdi1DYoSHEAoAIlRtc 3Ko0QKoaR6DmCcYDN13x2QHPbWug50/TakBnJd33TRtgqJopD5so5xpwVPzHKAdnOfN3 nzQA== X-Gm-Message-State: ALoCoQmJiTzFPOo7hWStkiUzFnm5Nsk+Nt7l5iaAle5FtNkDdHHGpaclVrvkRojllR2tuIXLLCvg X-Received: by 10.68.197.99 with SMTP id it3mr89988637pbc.37.1395883602078; Wed, 26 Mar 2014 18:26:42 -0700 (PDT) Received: from [192.168.1.102] (111-240-40-195.dynamic.hinet.net. [111.240.40.195]) by mx.google.com with ESMTPSA id q7sm1227147pbc.20.2014.03.26.18.26.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Mar 2014 18:26:41 -0700 (PDT) Message-ID: <1395883598.14364.0.camel@phoenix> Subject: [PATCH] spi: atmel: Make current_remaining_bytes to be int From: Axel Lin To: Mark Brown Cc: Wenyou Yang , linux-spi@vger.kernel.org Date: Thu, 27 Mar 2014 09:26:38 +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=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Don't use unsigned for current_remaining_bytes so we can check current_remaining_bytes < 0 case. Use int is enough for current_remaining_bytes. Signed-off-by: Axel Lin Signed-off-by: Wenyou Yang --- drivers/spi/spi-atmel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8005f98..485e6cc 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -224,7 +224,7 @@ struct atmel_spi { struct platform_device *pdev; struct spi_transfer *current_transfer; - unsigned long current_remaining_bytes; + int current_remaining_bytes; int done_status; struct completion xfer_completion; @@ -1110,6 +1110,8 @@ static int atmel_spi_one_transfer(struct spi_master *master, atmel_spi_next_xfer_pio(master, xfer); } else { as->current_remaining_bytes -= len; + if (as->current_remaining_bytes < 0) + as->current_remaining_bytes = 0; } } else { atmel_spi_next_xfer_pio(master, xfer);