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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CB20C7618A for ; Mon, 20 Mar 2023 17:18:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9005D85B66; Mon, 20 Mar 2023 18:18:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="p1FqeYdd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5141D85BC9; Mon, 20 Mar 2023 18:18:34 +0100 (CET) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D0B4C85B3F for ; Mon, 20 Mar 2023 18:18:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Reply-To: Content-ID:Content-Description; bh=xSULo0/rZkEfRCKfiUxTgRuAOrNw5HlpswjXLKw6SJk=; b=p1FqeYdd+GepD1COwIv9IvSM/+ xvoQ0jb5mV9WMcZX1zBXz8mpTjsc5bI+VVwQ20G2rpFnVm6MZqPb1WlLowYUt/2tMyg4zLqZMRrHK mI+SJv5985yNFEPV0edfzCMY+NSaAvsZLWymh+XT7X0ueEntA1TOC19JnX1ws1khLXZIw38p/mEGa 5n91pap7+4ltILrdYrH42ogGf0Vy5qxHjnfl6/0jTN7DGZQEcivrotXiufMClR9duwdFYOLY+sAPP xWUBSTlW04tDBY8U8rSxFRAYEJJ1bax4AbdS3/m66JzNJCBgIsLHAek6YDuUXmf4jhKjvjamFMRmw jZx3jpWA==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1peJ9O-0003OU-B4; Mon, 20 Mar 2023 17:18:27 +0000 From: John Keeping To: u-boot@lists.denx.de Cc: Simon Glass , Philipp Tomsich , Kever Yang , Jonas Karlman , John Keeping Subject: [PATCH v2 2/2] rockchip: otp: fix misc_read() return values Date: Mon, 20 Mar 2023 17:18:22 +0000 Message-Id: <20230320171822.1605531-3-john@metanate.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230320171822.1605531-1-john@metanate.com> References: <20230320171822.1605531-1-john@metanate.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The documentation for misc_read() says: Return: number of bytes read if OK (may be 0 if EOF), -ve on error The Rockchip efuse driver implements this so it should return the number of bytes read rather than zero on success. Fix this so that the driver follows the usual contract for read operations. Signed-off-by: John Keeping --- v2: - New patch drivers/misc/rockchip-otp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/misc/rockchip-otp.c b/drivers/misc/rockchip-otp.c index c19cd5ce62..4814e0e501 100644 --- a/drivers/misc/rockchip-otp.c +++ b/drivers/misc/rockchip-otp.c @@ -89,7 +89,7 @@ static int dump_otp(struct cmd_tbl *cmdtp, int flag, for (i = 0; true; i += sizeof(data)) { ret = misc_read(dev, i, &data, sizeof(data)); - if (ret < 0) + if (ret <= 0) return 0; print_buffer(i, data, 1, sizeof(data), sizeof(data)); @@ -249,8 +249,10 @@ static int rockchip_otp_read(struct udevice *dev, int offset, offset += data->offset; - if (data->block_size <= 1) - return data->read(dev, offset, buf, size); + if (data->block_size <= 1) { + ret = data->read(dev, offset, buf, size); + goto done; + } block_start = offset / data->block_size; block_offset = offset % data->block_size; @@ -266,7 +268,9 @@ static int rockchip_otp_read(struct udevice *dev, int offset, memcpy(buf, buffer + block_offset, size); free(buffer); - return ret; + +done: + return ret < 0 ? ret : size; } static const struct misc_ops rockchip_otp_ops = { -- 2.40.0