Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks
@ 2024-06-11 14:55 Joy Chakraborty
  2024-06-11 15:23 ` neil.armstrong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joy Chakraborty @ 2024-06-11 14:55 UTC (permalink / raw)
  To: Jerome Brunet, Martin Blumenstingl, Srinivas Kandagatla,
	Greg Kroah-Hartman, Dan Carpenter
  Cc: linux-arm-kernel, linux-amlogic, linux-kernel, Joy Chakraborty,
	stable

Read/write callbacks registered with nvmem core expect 0 to be returned
on success and a negative value to be returned on failure.

meson_efuse_read() and meson_efuse_write() call into
meson_sm_call_read() and meson_sm_call_write() respectively which return
the number of bytes read or written on success as per their api
description.

Fix to return error if meson_sm_call_read()/meson_sm_call_write()
returns an error else return 0.

Fixes: a29a63bdaf6f ("nvmem: meson-efuse: simplify read callback")
Cc: stable@vger.kernel.org
Signed-off-by: Joy Chakraborty <joychakr@google.com>
---
 drivers/nvmem/meson-efuse.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
index 52ed9a62ca5b..d7f9ac99a212 100644
--- a/drivers/nvmem/meson-efuse.c
+++ b/drivers/nvmem/meson-efuse.c
@@ -18,18 +18,24 @@ static int meson_efuse_read(void *context, unsigned int offset,
 			    void *val, size_t bytes)
 {
 	struct meson_sm_firmware *fw = context;
+	int ret;
 
-	return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
-				  bytes, 0, 0, 0);
+	ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
+				 bytes, 0, 0, 0);
+
+	return ret < 0 ? ret : 0;
 }
 
 static int meson_efuse_write(void *context, unsigned int offset,
 			     void *val, size_t bytes)
 {
 	struct meson_sm_firmware *fw = context;
+	int ret;
+
+	ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
+				  bytes, 0, 0, 0);
 
-	return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
-				   bytes, 0, 0, 0);
+	return ret < 0 ? ret : 0;
 }
 
 static const struct of_device_id meson_efuse_match[] = {
-- 
2.45.2.505.gda0bf45e8d-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks
  2024-06-11 14:55 [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks Joy Chakraborty
@ 2024-06-11 15:23 ` neil.armstrong
  2024-06-11 15:28 ` Dan Carpenter
  2024-06-21  6:20 ` Srinivas Kandagatla
  2 siblings, 0 replies; 4+ messages in thread
From: neil.armstrong @ 2024-06-11 15:23 UTC (permalink / raw)
  To: Joy Chakraborty, Jerome Brunet, Martin Blumenstingl,
	Srinivas Kandagatla, Greg Kroah-Hartman, Dan Carpenter
  Cc: linux-arm-kernel, linux-amlogic, linux-kernel, stable

On 11/06/2024 16:55, Joy Chakraborty wrote:
> Read/write callbacks registered with nvmem core expect 0 to be returned
> on success and a negative value to be returned on failure.
> 
> meson_efuse_read() and meson_efuse_write() call into
> meson_sm_call_read() and meson_sm_call_write() respectively which return
> the number of bytes read or written on success as per their api
> description.
> 
> Fix to return error if meson_sm_call_read()/meson_sm_call_write()
> returns an error else return 0.
> 
> Fixes: a29a63bdaf6f ("nvmem: meson-efuse: simplify read callback")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joy Chakraborty <joychakr@google.com>
> ---
>   drivers/nvmem/meson-efuse.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
> index 52ed9a62ca5b..d7f9ac99a212 100644
> --- a/drivers/nvmem/meson-efuse.c
> +++ b/drivers/nvmem/meson-efuse.c
> @@ -18,18 +18,24 @@ static int meson_efuse_read(void *context, unsigned int offset,
>   			    void *val, size_t bytes)
>   {
>   	struct meson_sm_firmware *fw = context;
> +	int ret;
>   
> -	return meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
> -				  bytes, 0, 0, 0);
> +	ret = meson_sm_call_read(fw, (u8 *)val, bytes, SM_EFUSE_READ, offset,
> +				 bytes, 0, 0, 0);
> +
> +	return ret < 0 ? ret : 0;
>   }
>   
>   static int meson_efuse_write(void *context, unsigned int offset,
>   			     void *val, size_t bytes)
>   {
>   	struct meson_sm_firmware *fw = context;
> +	int ret;
> +
> +	ret = meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
> +				  bytes, 0, 0, 0);
>   
> -	return meson_sm_call_write(fw, (u8 *)val, bytes, SM_EFUSE_WRITE, offset,
> -				   bytes, 0, 0, 0);
> +	return ret < 0 ? ret : 0;
>   }
>   
>   static const struct of_device_id meson_efuse_match[] = {

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks
  2024-06-11 14:55 [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks Joy Chakraborty
  2024-06-11 15:23 ` neil.armstrong
@ 2024-06-11 15:28 ` Dan Carpenter
  2024-06-21  6:20 ` Srinivas Kandagatla
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-06-11 15:28 UTC (permalink / raw)
  To: Joy Chakraborty
  Cc: Jerome Brunet, Martin Blumenstingl, Srinivas Kandagatla,
	Greg Kroah-Hartman, linux-arm-kernel, linux-amlogic, linux-kernel,
	stable

On Tue, Jun 11, 2024 at 02:55:24PM +0000, Joy Chakraborty wrote:
> Read/write callbacks registered with nvmem core expect 0 to be returned
> on success and a negative value to be returned on failure.
> 
> meson_efuse_read() and meson_efuse_write() call into
> meson_sm_call_read() and meson_sm_call_write() respectively which return
> the number of bytes read or written on success as per their api
> description.
> 
> Fix to return error if meson_sm_call_read()/meson_sm_call_write()
> returns an error else return 0.
> 
> Fixes: a29a63bdaf6f ("nvmem: meson-efuse: simplify read callback")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joy Chakraborty <joychakr@google.com>

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>

regards,
dan carpenter


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks
  2024-06-11 14:55 [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks Joy Chakraborty
  2024-06-11 15:23 ` neil.armstrong
  2024-06-11 15:28 ` Dan Carpenter
@ 2024-06-21  6:20 ` Srinivas Kandagatla
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2024-06-21  6:20 UTC (permalink / raw)
  To: Jerome Brunet, Martin Blumenstingl, Greg Kroah-Hartman,
	Dan Carpenter, Joy Chakraborty
  Cc: linux-arm-kernel, linux-amlogic, linux-kernel, stable


On Tue, 11 Jun 2024 14:55:24 +0000, Joy Chakraborty wrote:
> Read/write callbacks registered with nvmem core expect 0 to be returned
> on success and a negative value to be returned on failure.
> 
> meson_efuse_read() and meson_efuse_write() call into
> meson_sm_call_read() and meson_sm_call_write() respectively which return
> the number of bytes read or written on success as per their api
> description.
> 
> [...]

Applied, thanks!

[1/1] nvmem: meson-efuse: Fix return value of nvmem callbacks
      commit: c87ba397647e1ad84d2771461a6035a63d388198

Best regards,
-- 
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-21  6:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11 14:55 [PATCH] nvmem: meson-efuse: Fix return value of nvmem callbacks Joy Chakraborty
2024-06-11 15:23 ` neil.armstrong
2024-06-11 15:28 ` Dan Carpenter
2024-06-21  6:20 ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox