Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1780875iob; Thu, 5 May 2022 08:06:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5lvEh8EVZE/Zl2gfy9YAuSlnYLy5dXDZeR/OjVufHCaT5iElhHqb9UxEmJe1rZdhdDAPX X-Received: by 2002:a05:6638:22c3:b0:32b:8e0e:c276 with SMTP id j3-20020a05663822c300b0032b8e0ec276mr4508905jat.204.1651763204134; Thu, 05 May 2022 08:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651763204; cv=none; d=google.com; s=arc-20160816; b=ElYNzLT3ma7SJUxfmkay0zS8dDzqdoQs+uu3wsdMrw9FSVSWd/WuWubQ/DjsmrTB1F BVQLQcE0+uuiL/HF2FOGojwNvpwy+c2jHZfhqFbKcA/CSvsTCz92zVKCfLVS0SY8xhUt eKIm6qY/bUoWskkwkvxM/e6HxQfP6eEwZ/PTVJYrZ52aUmcAdlaTWQCaXVrnTVdzESDa 4sh2RPAkI3oWgpueXZOnqyL8y4GEu8f+AMkMWHpH2HrqGR+wAVRTZsj5+5572Kmb3hDy vRYZ6cXyMUZVLEjVcY0V3Ou/E/iyVJYXsHEtbWatFE0A8OlV6lg37CLSj8//pg3GUxVf jDqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wxs6ApqLukGL6Lo3pBmXeQsgaDgJqkglE50esOZ/2hU=; b=z5zMjTwc910/JIPXZGBPZIUS+tRlamT72ZyDeImjAqT4TD04tIriNGYMPUtgfOwmUk oF1jXWUWWSgVPWXrrn9zgBM1AbGEbshH6aDTAP2qxQjRBorVQcgwfqG616RjsElEakq/ oN09zmS/DNNDRk6caeLArwBxLb3LNMzNaYBQWyOJKIm0Dn59QM/1IC8pzBCdqSljnNsw RnDDzJb/XcnkHGxljVfQDxVhDJNNROLswZyKv+I1xzjFfdwXZoP71GeVV9Wm6mbTqRCl NaRrJZn//Z2gkAQn4Gad3eXKYt0IusjbeqxFLcsymhAGfFWSWsrshd470Wm96V5eAzzo HKrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0KxEvr9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r137-20020a6b2b8f000000b0065309877af8si828858ior.65.2022.05.05.08.06.27; Thu, 05 May 2022 08:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0KxEvr9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239742AbiEDRRe (ORCPT + 99 others); Wed, 4 May 2022 13:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356074AbiEDREw (ORCPT ); Wed, 4 May 2022 13:04:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 381845007F; Wed, 4 May 2022 09:53:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D107FB8278E; Wed, 4 May 2022 16:53:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88FFAC385AA; Wed, 4 May 2022 16:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683223; bh=zDziTLnsss2snsLkpWMuxnhSovQWKHnxQj50ZFeHjpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0KxEvr9E0QHfWQN/4U/lLrgNADzrOK+dSsf5wC4IeTZ020hvVuz6C+4nSUC/WcCT N8RJbOJQ7WRuLnVAFJA18sYJmwrOZSWdsCk67DQ11Rq5R529OKGQdzE+7Miy+IW0Vd cigBihkuZkONZatMtei5j6cQtJP8n/WKCCxhCS/o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Miquel Raynal , Sasha Levin Subject: [PATCH 5.15 076/177] mtd: rawnand: Fix return value check of wait_for_completion_timeout Date: Wed, 4 May 2022 18:44:29 +0200 Message-Id: <20220504153059.888618092@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin [ Upstream commit 084c16ab423a8890121b902b405823bfec5b4365 ] wait_for_completion_timeout() returns unsigned long not int. 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: 83738d87e3a0 ("mtd: sh_flctl: Add DMA capabilty") Signed-off-by: Miaoqian Lin Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20220412083435.29254-1-linmq006@gmail.com Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/sh_flctl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/nand/raw/sh_flctl.c b/drivers/mtd/nand/raw/sh_flctl.c index 13df4bdf792a..8f89e2d3d817 100644 --- a/drivers/mtd/nand/raw/sh_flctl.c +++ b/drivers/mtd/nand/raw/sh_flctl.c @@ -384,7 +384,8 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf, dma_addr_t dma_addr; dma_cookie_t cookie; uint32_t reg; - int ret; + int ret = 0; + unsigned long time_left; if (dir == DMA_FROM_DEVICE) { chan = flctl->chan_fifo0_rx; @@ -425,13 +426,14 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf, goto out; } - ret = + time_left = wait_for_completion_timeout(&flctl->dma_complete, msecs_to_jiffies(3000)); - if (ret <= 0) { + if (time_left == 0) { dmaengine_terminate_all(chan); dev_err(&flctl->pdev->dev, "wait_for_completion_timeout\n"); + ret = -ETIMEDOUT; } out: @@ -441,7 +443,7 @@ static int flctl_dma_fifo0_transfer(struct sh_flctl *flctl, unsigned long *buf, dma_unmap_single(chan->device->dev, dma_addr, len, dir); - /* ret > 0 is success */ + /* ret == 0 is success */ return ret; } @@ -465,7 +467,7 @@ static void read_fiforeg(struct sh_flctl *flctl, int rlen, int offset) /* initiate DMA transfer */ if (flctl->chan_fifo0_rx && rlen >= 32 && - flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_FROM_DEVICE) > 0) + !flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_FROM_DEVICE)) goto convert; /* DMA success */ /* do polling transfer */ @@ -524,7 +526,7 @@ static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen, /* initiate DMA transfer */ if (flctl->chan_fifo0_tx && rlen >= 32 && - flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_TO_DEVICE) > 0) + !flctl_dma_fifo0_transfer(flctl, buf, rlen, DMA_TO_DEVICE)) return; /* DMA success */ /* do polling transfer */ -- 2.35.1