Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3311178yba; Sun, 28 Apr 2019 23:13:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzU2QejQwNDMV3Xa8iWH8NaBtY0RvF7jC2+5cgbx+AALG3k6vPYrHEmPRCV2jJDPboP1uOE X-Received: by 2002:a63:5d46:: with SMTP id o6mr22346915pgm.217.1556518427993; Sun, 28 Apr 2019 23:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556518427; cv=none; d=google.com; s=arc-20160816; b=Z7kVsFiKRZOs/VH1/9ISiLQTSysklZ74zSt+iD/TXwiS8+w8g2BOdACYVLspV18VQP 5goXWk1oXZavX1jsLAKWik6ug+ueVD/LqrBZyITuQYhSSzC11ZWidcoR+B2OPdiEljsp +GsK9SEKHBxqweJ7ERTgyofZEm91o44GXjRA9b7I1cKgC7FDgguB/AWTkeC/JLR8bjO+ KZtHkQxQ8hwWYGdlcpcP4ZSPNqTrTT/o9CU5NcAZ444FxXrphtUVgJpYq2bq25mMEkCr 4urIagir0UPxECz+KgUGnuw7ZSL5kRZ5KCdHJI2VL2ECbO0u3avybwNDRcrLMH2c/rZ5 O2bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=VzKOo1Xm9MhFP3DcJ70JHZjWP/AHz89N74Ti/H1f/rE=; b=SP91AQG43CxpnMcRfp4lEJ38x+nwekh7kOCyMmMSrTYx8MjfzwlZLUSgnfgascTqU0 qeHimqcNS/hHWvmMrIX09D+R9zvqZJjqgQOjsunk8uWvVRnJufMVYDLViRURG3dvpVsO MLiExM3bDHH4+HC1WbvmoQEBeeBEKFsoPLRTCZLXttQa8mdh/RsprDi6YkB4qLF1rVNP a9e20dwfc9f687+cNFTHLh+DxevvgjcF6HlwDZ2Pg0yggwZyxiA2RZ9v+9KFpat4Hcwb rnKyQ7sFE8bhZtmouK0a83ig+IYQlNozgHw9Aau+kSUJ5uVv3lgubWSe+3uqXdz0XAFl Qa2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7si14024690pgo.284.2019.04.28.23.13.33; Sun, 28 Apr 2019 23:13:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727425AbfD2GLi (ORCPT + 99 others); Mon, 29 Apr 2019 02:11:38 -0400 Received: from www.osadl.org ([62.245.132.105]:41116 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbfD2GLi (ORCPT ); Mon, 29 Apr 2019 02:11:38 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x3T6BEmb005090; Mon, 29 Apr 2019 08:11:27 +0200 From: Nicholas Mc Guire To: Greg Kroah-Hartman Cc: Sven Van Asbroeck , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH V3] staging: fieldbus: anybus-s: consolidate wait_for_completion_timeout return handling Date: Mon, 29 Apr 2019 08:05:40 +0200 Message-Id: <1556517940-13725-2-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1556517940-13725-1-git-send-email-hofrat@osadl.org> References: <1556517940-13725-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=0.4 required=6.0 tests=BAYES_00,DATE_IN_FUTURE_96_Q autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wait_for_completion_timeout() returns unsigned long (0 on timeout or remaining jiffies) not int - so this type error allows for a theoretically int overflow - though not in this case where TIMEOUT is only HZ*2). To fix this type inconsistency the completion is wrapped into the if() rather than introducing an additional unsigned long variable. Along with fixing this type inconsistency the fall-through if is consolidated to a single if-block. Signed-off-by: Nicholas Mc Guire --- Problem located with experimental API conformance checking cocci script V3: As requested by Sven Van Asbroeck cleanup the commit message to make it more clear what the impact of the proposed change is....lets see if this is any better. V2: The original patch's logic was wrong as it was skipping the fall-through if so using the fix proposed by Sven Van Asbroeck - This solution also eliminates the need to introduce an additional variable - Thanks ! Patch was compile-tested with. x86_64_defconfig + OF=y, FIELDBUS_DEV=m, HMS_ANYBUSS_BUS=m (with an unrelated sparse warnings (cast to restricted __be16)) Patch is against 5.1-rc6 (localversion-next is next-20190426) drivers/staging/fieldbus/anybuss/host.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c index e34d424..6227daf 100644 --- a/drivers/staging/fieldbus/anybuss/host.c +++ b/drivers/staging/fieldbus/anybuss/host.c @@ -1325,11 +1325,11 @@ anybuss_host_common_probe(struct device *dev, * interrupt came in: ready to go ! */ reset_deassert(cd); - ret = wait_for_completion_timeout(&cd->card_boot, TIMEOUT); - if (ret == 0) + if (!wait_for_completion_timeout(&cd->card_boot, TIMEOUT)) { ret = -ETIMEDOUT; - if (ret < 0) goto err_reset; + } + /* * according to the anybus docs, we're allowed to read these * without handshaking / reserving the area -- 2.1.4