From patchwork Sat Dec 27 11:48:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 424189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 20D7D14007F for ; Sat, 27 Dec 2014 23:01:44 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751081AbaL0MBm (ORCPT ); Sat, 27 Dec 2014 07:01:42 -0500 Received: from www.osadl.org ([62.245.132.105]:59194 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbaL0MBl (ORCPT ); Sat, 27 Dec 2014 07:01:41 -0500 X-Greylist: delayed 525 seconds by postgrey-1.27 at vger.kernel.org; Sat, 27 Dec 2014 07:01:40 EST Received: from debian.hofrr.at (92-243-35-153.adsl.nanet.at [92.243.35.153] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id sBRBqRIH020694; Sat, 27 Dec 2014 12:52:27 +0100 From: Nicholas Mc Guire To: Wolfram Sang Cc: Grant Likely , Rob Herring , Yao Yuan , Fugang Duan , Fabio Estevam , Jingoo Han , Kaushal Butala , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] fix handling of wait_for_completion_timeout result Date: Sat, 27 Dec 2014 06:48:50 -0500 Message-Id: <1419680930-9052-1-git-send-email-der.herr@hofr.at> X-Mailer: git-send-email 1.7.10.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, KHOP_SC_TOP_CIDR8, RDNS_DYNAMIC autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org wati_for_completion_timeout does not return negative values so "result" handlin here should be simplified to cover the actually possible cases only. patch was only compile tested for imx_v6_v7_defconfig patch is against 3.19.0-rc1 -next-20141226 Signed-off-by: Nicholas Mc Guire --- drivers/i2c/busses/i2c-imx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 7f3a9fe..2be7d9d 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -628,9 +628,9 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx, result = wait_for_completion_timeout( &i2c_imx->dma->cmd_complete, msecs_to_jiffies(DMA_TIMEOUT)); - if (result <= 0) { + if (result == 0) { dmaengine_terminate_all(dma->chan_using); - return result ?: -ETIMEDOUT; + return -ETIMEDOUT; } /* Waiting for transfer complete. */ @@ -686,9 +686,9 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx, result = wait_for_completion_timeout( &i2c_imx->dma->cmd_complete, msecs_to_jiffies(DMA_TIMEOUT)); - if (result <= 0) { + if (result == 0) { dmaengine_terminate_all(dma->chan_using); - return result ?: -ETIMEDOUT; + return -ETIMEDOUT; } /* waiting for transfer complete. */