All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: devices: check mtd_device_register() return code
@ 2018-03-24 11:18 Arushi Singhal
  2018-05-03 10:00 ` Boris Brezillon
  0 siblings, 1 reply; 4+ messages in thread
From: Arushi Singhal @ 2018-03-24 11:18 UTC (permalink / raw)
  To: dwmw2
  Cc: Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
	Cyrille Pitchen, linux-mtd, linux-kernel

stfsm_probe() misses error handling of mtd_device_register().

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
 drivers/mtd/devices/st_spi_fsm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index 7bc29d7..4a99a6a 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -2125,7 +2125,13 @@ static int stfsm_probe(struct platform_device *pdev)
 		(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
 		fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
 
-	return mtd_device_register(&fsm->mtd, NULL, 0);
+	ret = mtd_device_register(&fsm->mtd, NULL, 0);
+	if (ret) {
+		pr_err("Failed to register device\n");
+		goto err_clk_unprepare;
+	}
+
+	return 0;
 
 err_clk_unprepare:
 	clk_disable_unprepare(fsm->clk);
-- 
2.7.4

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

* Re: [PATCH] mtd: devices: check mtd_device_register() return code
  2018-03-24 11:18 [PATCH] mtd: devices: check mtd_device_register() return code Arushi Singhal
@ 2018-05-03 10:00 ` Boris Brezillon
  0 siblings, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-05-03 10:00 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: dwmw2, Boris Brezillon, Richard Weinberger, linux-kernel,
	Marek Vasut, linux-mtd, Cyrille Pitchen, Brian Norris

On Sat, 24 Mar 2018 16:48:20 +0530
Arushi Singhal <arushisinghal19971997@gmail.com> wrote:

Subject prefix should be "mtd: devices: st_spi_fsm: ", and it's really
about checking return code which was already propagated to the lower
layer (platform bus), but it's about making sure we disable the clk we
have previously enabled in case of failure.

BTW, I see that the clk is not disabled in ->remove(), probably
something we should fix too (in a separate patch).

> stfsm_probe() misses error handling of mtd_device_register().
> 
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
>  drivers/mtd/devices/st_spi_fsm.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
> index 7bc29d7..4a99a6a 100644
> --- a/drivers/mtd/devices/st_spi_fsm.c
> +++ b/drivers/mtd/devices/st_spi_fsm.c
> @@ -2125,7 +2125,13 @@ static int stfsm_probe(struct platform_device *pdev)
>  		(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
>  		fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
>  
> -	return mtd_device_register(&fsm->mtd, NULL, 0);
> +	ret = mtd_device_register(&fsm->mtd, NULL, 0);
> +	if (ret) {
> +		pr_err("Failed to register device\n");
> +		goto err_clk_unprepare;
> +	}
> +
> +	return 0;
>  
>  err_clk_unprepare:
>  	clk_disable_unprepare(fsm->clk);

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

* Re: [PATCH] mtd: devices: check mtd_device_register() return code
  2018-03-21  5:37 Arushi Singhal
@ 2018-03-21  8:01 ` Miquel Raynal
  0 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2018-03-21  8:01 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: dwmw2, Boris Brezillon, Richard Weinberger, linux-kernel,
	Marek Vasut, linux-mtd, Cyrille Pitchen, Brian Norris

Hi Arushi,

On Wed, 21 Mar 2018 11:07:09 +0530, Arushi Singhal
<arushisinghal19971997@gmail.com> wrote:

> stfsm_probe() misses error handling of mtd_device_register().
> 
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
>  drivers/mtd/devices/st_spi_fsm.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
> index 7bc29d7..e1aa4f8 100644
> --- a/drivers/mtd/devices/st_spi_fsm.c
> +++ b/drivers/mtd/devices/st_spi_fsm.c
> @@ -2125,7 +2125,13 @@ static int stfsm_probe(struct platform_device *pdev)
>  		(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
>  		fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
>  
> -	return mtd_device_register(&fsm->mtd, NULL, 0);
> +	ret = mtd_device_register(&fsm->mtd, NULL, 0);
> +	if (ret) {
> +		pr_err("Failed to register device\n");
> +		return ret;
> +	}
> +
> +	return 0;

I don't think this bring anything. However, if you want to fix
something you should jump below on error to disable the clock instead
of returning 'ret' directly.

>  
>  err_clk_unprepare:
>  	clk_disable_unprepare(fsm->clk);

Thanks,
Miquèl

-- 
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [PATCH] mtd: devices: check mtd_device_register() return code
@ 2018-03-21  5:37 Arushi Singhal
  2018-03-21  8:01 ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Arushi Singhal @ 2018-03-21  5:37 UTC (permalink / raw)
  To: dwmw2
  Cc: Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
	Cyrille Pitchen, linux-mtd, linux-kernel

stfsm_probe() misses error handling of mtd_device_register().

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
 drivers/mtd/devices/st_spi_fsm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index 7bc29d7..e1aa4f8 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -2125,7 +2125,13 @@ static int stfsm_probe(struct platform_device *pdev)
 		(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
 		fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
 
-	return mtd_device_register(&fsm->mtd, NULL, 0);
+	ret = mtd_device_register(&fsm->mtd, NULL, 0);
+	if (ret) {
+		pr_err("Failed to register device\n");
+		return ret;
+	}
+
+	return 0;
 
 err_clk_unprepare:
 	clk_disable_unprepare(fsm->clk);
-- 
2.7.4

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

end of thread, other threads:[~2018-05-03 10:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-24 11:18 [PATCH] mtd: devices: check mtd_device_register() return code Arushi Singhal
2018-05-03 10:00 ` Boris Brezillon
  -- strict thread matches above, loose matches on Subject: below --
2018-03-21  5:37 Arushi Singhal
2018-03-21  8:01 ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.