From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A17FDCE7A94 for ; Mon, 25 Sep 2023 14:03:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbjIYODS convert rfc822-to-8bit (ORCPT ); Mon, 25 Sep 2023 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbjIYODQ (ORCPT ); Mon, 25 Sep 2023 10:03:16 -0400 Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9A9109 for ; Mon, 25 Sep 2023 07:03:06 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 84C78635DB5B; Mon, 25 Sep 2023 16:03:04 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id IuqLOyVDcGkJ; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 932CE622F591; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id slzN9QCr4ZQj; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id 71238635DB5B; Mon, 25 Sep 2023 16:03:03 +0200 (CEST) Date: Mon, 25 Sep 2023 16:03:03 +0200 (CEST) From: Richard Weinberger To: ZhaoLong Wang Cc: Miquel Raynal , Vignesh Raghavendra , linux-mtd , linux-kernel , chengzhihao1 , yi zhang , yangerkun Message-ID: <1131184426.81026.1695650583370.JavaMail.zimbra@nod.at> In-Reply-To: <20230923005856.2538223-1-wangzhaolong1@huawei.com> References: <20230923005856.2538223-1-wangzhaolong1@huawei.com> Subject: Re: [RFC] mtd: Fix error code loss in mtdchar_read() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF97 (Linux)/8.8.12_GA_3809) Thread-Topic: Fix error code loss in mtdchar_read() function. Thread-Index: K2deZwmqse54Lnhyky63J7p7EYeVMQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Ursprüngliche Mail ----- > Von: "ZhaoLong Wang" > An: "Miquel Raynal" , "richard" , "Vignesh Raghavendra" > CC: "linux-mtd" , "linux-kernel" , "chengzhihao1" > , "ZhaoLong Wang" , "yi zhang" , "yangerkun" > > Gesendet: Samstag, 23. September 2023 02:58:56 > Betreff: [RFC] mtd: Fix error code loss in mtdchar_read() function. > In the first while loop, if the mtd_read() function returns -EBADMSG > and 'retlen' returns 0, the loop break and the function returns value > 'total_retlen' is 0, not the error code. Given this a second thought. I don't think a NAND driver is allowed to return less than requests bytes and setting EBADMSG. UBI's IO path has a comment on that: /* * The driver should never return -EBADMSG if it failed to read * all the requested data. But some buggy drivers might do * this, so we change it to -EIO. */ if (read != len && mtd_is_eccerr(err)) { ubi_assert(0); err = -EIO; } Thanks, //richard