From patchwork Tue Apr 12 01:55:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 12809953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3BC3C433F5 for ; Tue, 12 Apr 2022 01:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lQgzDWJsn9AUfHRJdOTwzYZnniCUtx46x43dx1LLsGc=; b=1wotDJQMHlOvPu QXEjp5EZp9DUtm8TMBkJbwmt/cXuGOV+JtZdtEHQ5TXQIWh0l3SQCvkVurMcq1kN4lCoR213jaPjw Dn3/hDR8NDi8rkRZwgj/24Z8mT+EDlv4CFfMYjqYIMUme329/B6ooVO3Z36qOR5QLj6j6sCtHl30p /i7MoKTJD4qVE4u2Eal3A+rtmCfu1nSmRPRXq3LgCUwIkibvRjRb5CySH3IBxE6b6wjTyR+1OtnGo 6Qnofn/o5grEOuH+3GeEQlkF9yscYtXR2R32w2QZdYtAueEp1UTOE25kWppqYzyuGIZa/7OFPVsO9 PzSj5aPY8P9Ab7jg5AvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ne5lq-00BCmz-Hm; Tue, 12 Apr 2022 01:56:42 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ne5ln-00BCmb-EZ for linux-arm-kernel@lists.infradead.org; Tue, 12 Apr 2022 01:56:40 +0000 Received: by mail-pg1-x533.google.com with SMTP id s137so13068252pgs.5 for ; Mon, 11 Apr 2022 18:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references; bh=sM5FjahbxiDWtBMcPGoH6sjK50a41Jzz6Kf8kK5IDIA=; b=Vb/IP0/ckbo8JnxvOIqofc/GCxVL5OwLwa2/kVvlfWhHBj5G7Byk5xMS+tct28pghZ TjiX3jRqDNqNJRMws9ao6amJT7UsZ34eigDIyTwmZMS7Ni61Mi/olKMbLZdYFvQxdj42 57TwBOzAz7v5OFbDeALkA+a0kLtLFJJcN5kmFvgTZR5LrhWchnZNNsKENwWvJshWtCl6 AtCcacnD6C2Oi/X8J77PhIIFq2QSY09G/tzc/a16o6RnMxR4amjp6NXs7RcKSBab8wzG FOcfqhL/QCvsohG7Vzqypqru1DVwekKsExWvYpZgT/dYWMf34rGB4kQSUED4UgIscY3w bmaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=sM5FjahbxiDWtBMcPGoH6sjK50a41Jzz6Kf8kK5IDIA=; b=OsCyLAge+yEmwy2fbiKaRZQEqMAEUOnpKsH4r5siSYFEebNI/s5jX3KPJIfSlkb8jG UdtvXEi+SmssjxBWXqMAX+ppoHyVSDgK87e1dzWK3Y4mGa/mjLQF7Ua3XicSp/SMLB2f gLSUjc9ezdlvZ6ncg91jPUvDGSNHHhIKBwnl7QLPWSmA1nSoF3DNGV69L+KKqQduBigy 822K6apJaEzobD3fsz9/I0ryJgrbivYod+eVYwCHkWkjp0x58cOpvhaLlgKhOrQfLKh1 1MLD3WQyzZLINe7IhRT8RK1ttbw/g5iQRiuaG2oX7zLTbm6ymwKc/6qmQ7BcAN7lNRyN LSXg== X-Gm-Message-State: AOAM533CbQHMQrLixxD8c5TafK9vcFF/HcJ3m90Ym3KlefcJqHaq/mvX 9PftX/5JKFRHlITiG1ADNko= X-Google-Smtp-Source: ABdhPJxaKYnF/FBKWSQfNDG/CffffK+XXw6W3BSTU7WQBeJ+uvZ16E1x2om5zLruk4LPuCuEc+5eJg== X-Received: by 2002:a63:140f:0:b0:399:3005:baf5 with SMTP id u15-20020a63140f000000b003993005baf5mr29409036pgl.193.1649728598072; Mon, 11 Apr 2022 18:56:38 -0700 (PDT) Received: from localhost.localdomain ([159.226.95.43]) by smtp.googlemail.com with ESMTPSA id gn21-20020a17090ac79500b001ca3c37af65sm746815pjb.21.2022.04.11.18.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 18:56:37 -0700 (PDT) From: Miaoqian Lin To: Jonathan Cameron , Lars-Peter Clausen , Maxime Coquelin , Alexandre Torgue , Kees Cook , Miaoqian Lin , Philippe Schenker , linux-iio@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] iio: stmpe-adc: Fix wait_for_completion_timeout return value check Date: Tue, 12 Apr 2022 01:55:42 +0000 Message-Id: <20220412015547.4137-1-linmq006@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <60e67c07-7e40-4187-a90a-1be9acdfe757@gmail.com> References: <60e67c07-7e40-4187-a90a-1be9acdfe757@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220411_185639_528967_17E02BCB X-CRM114-Status: GOOD ( 14.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org wait_for_completion_timeout() returns unsigned long not long. it returns 0 if timed out, and positive if completed. The check for <= 0 is ambiguous and should be == 0 here indicating timeout which is the only error case Fixes: e813dde6f833 ("iio: stmpe-adc: Use wait_for_completion_timeout") Signed-off-by: Miaoqian Lin Reviewed-by: Nuno Sá --- changes in v2: - Fix same issue in stmpe_read_temp. --- drivers/iio/adc/stmpe-adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index d2d405388499..83e0ac4467ca 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -61,7 +61,7 @@ struct stmpe_adc { static int stmpe_read_voltage(struct stmpe_adc *info, struct iio_chan_spec const *chan, int *val) { - long ret; + unsigned long ret; mutex_lock(&info->lock); @@ -79,7 +79,7 @@ static int stmpe_read_voltage(struct stmpe_adc *info, ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); - if (ret <= 0) { + if (ret == 0) { stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_STA, STMPE_ADC_CH(info->channel)); mutex_unlock(&info->lock); @@ -96,7 +96,7 @@ static int stmpe_read_voltage(struct stmpe_adc *info, static int stmpe_read_temp(struct stmpe_adc *info, struct iio_chan_spec const *chan, int *val) { - long ret; + unsigned long ret; mutex_lock(&info->lock); @@ -114,7 +114,7 @@ static int stmpe_read_temp(struct stmpe_adc *info, ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); - if (ret <= 0) { + if (ret == 0) { mutex_unlock(&info->lock); return -ETIMEDOUT; }