diff mbox series

[v3,1/3] rockchip: misc: fix misc_read() return check

Message ID 20230327110110.1312992-2-john@metanate.com
State Accepted
Commit 999680c4ed80e21e014e94c9bdb79c45a5a5a853
Delegated to: Kever Yang
Headers show
Series rockchip: fix efuse/otp misc_read return values | expand

Commit Message

John Keeping March 27, 2023, 11:01 a.m. UTC
misc_read() is documented to return the number of bytes read or a
negative error value.  The Rockchip drivers currently do not implement
this correctly and instead return zero on success or a negative error
value.

In preparation for fixing the drivers, fix the condition here to only
error on negative values.

Suggested-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: John Keeping <john@metanate.com>
---
v3: new patch

 arch/arm/mach-rockchip/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass March 27, 2023, 7:02 p.m. UTC | #1
On Tue, 28 Mar 2023 at 00:01, John Keeping <john@metanate.com> wrote:
>
> misc_read() is documented to return the number of bytes read or a
> negative error value.  The Rockchip drivers currently do not implement
> this correctly and instead return zero on success or a negative error
> value.
>
> In preparation for fixing the drivers, fix the condition here to only
> error on negative values.
>
> Suggested-by: Jonas Karlman <jonas@kwiboo.se>
> Signed-off-by: John Keeping <john@metanate.com>
> ---
> v3: new patch
>
>  arch/arm/mach-rockchip/misc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Kever Yang April 14, 2023, 8:50 a.m. UTC | #2
On 2023/3/27 19:01, John Keeping wrote:
> misc_read() is documented to return the number of bytes read or a
> negative error value.  The Rockchip drivers currently do not implement
> this correctly and instead return zero on success or a negative error
> value.
>
> In preparation for fixing the drivers, fix the condition here to only
> error on negative values.
>
> Suggested-by: Jonas Karlman <jonas@kwiboo.se>
> Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
> v3: new patch
>
>   arch/arm/mach-rockchip/misc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
> index 849014d2fb..7d03f0c2b6 100644
> --- a/arch/arm/mach-rockchip/misc.c
> +++ b/arch/arm/mach-rockchip/misc.c
> @@ -83,7 +83,7 @@ int rockchip_cpuid_from_efuse(const u32 cpuid_offset,
>   
>   	/* read the cpu_id range from the efuses */
>   	ret = misc_read(dev, cpuid_offset, cpuid, cpuid_length);
> -	if (ret) {
> +	if (ret < 0) {
>   		debug("%s: reading cpuid from the efuses failed\n",
>   		      __func__);
>   		return -1;
diff mbox series

Patch

diff --git a/arch/arm/mach-rockchip/misc.c b/arch/arm/mach-rockchip/misc.c
index 849014d2fb..7d03f0c2b6 100644
--- a/arch/arm/mach-rockchip/misc.c
+++ b/arch/arm/mach-rockchip/misc.c
@@ -83,7 +83,7 @@  int rockchip_cpuid_from_efuse(const u32 cpuid_offset,
 
 	/* read the cpu_id range from the efuses */
 	ret = misc_read(dev, cpuid_offset, cpuid, cpuid_length);
-	if (ret) {
+	if (ret < 0) {
 		debug("%s: reading cpuid from the efuses failed\n",
 		      __func__);
 		return -1;