diff mbox series

[3/4] spi: mt7621: Use devm_spi_register_controller()

Message ID b7698e198acc998d99e7e7c895a2910f14f89443.1661599671.git.christophe.jaillet@wanadoo.fr
State Accepted
Commit 30b31b29a866d32fc381b406d4c4f5db2636e5ec
Headers show
Series spi: mt7621: Fix an erroneous message + clean-ups | expand

Commit Message

Christophe JAILLET Aug. 27, 2022, 11:42 a.m. UTC
Now that clk_disable_unprepare(clk) is handled with a managed resource,
we can use devm_spi_register_controller() and axe the .remove function.

The order between spi_unregister_controller() and clk_disable_unprepare()
is still the same.
(see commit 46b5c4fb87ce ("spi: mt7621: Don't leak SPI master in probe
error path") to see why it matters)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
I guess that the dev_set_drvdata() in the probe can be removed as-well.
But it is also harmless to leave it as-is.
---
 drivers/spi/spi-mt7621.c | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

Comments

Matthias Brugger Aug. 29, 2022, 11:16 a.m. UTC | #1
On 27/08/2022 13:42, Christophe JAILLET wrote:
> Now that clk_disable_unprepare(clk) is handled with a managed resource,
> we can use devm_spi_register_controller() and axe the .remove function.
> 
> The order between spi_unregister_controller() and clk_disable_unprepare()
> is still the same.
> (see commit 46b5c4fb87ce ("spi: mt7621: Don't leak SPI master in probe
> error path") to see why it matters)
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
> I guess that the dev_set_drvdata() in the probe can be removed as-well.
> But it is also harmless to leave it as-is.
> ---
>   drivers/spi/spi-mt7621.c | 16 +---------------
>   1 file changed, 1 insertion(+), 15 deletions(-)
> 
> diff --git a/drivers/spi/spi-mt7621.c b/drivers/spi/spi-mt7621.c
> index 2580b28042be..114f98dcae5e 100644
> --- a/drivers/spi/spi-mt7621.c
> +++ b/drivers/spi/spi-mt7621.c
> @@ -373,20 +373,7 @@ static int mt7621_spi_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	ret = spi_register_controller(master);
> -
> -	return ret;
> -}
> -
> -static int mt7621_spi_remove(struct platform_device *pdev)
> -{
> -	struct spi_controller *master;
> -
> -	master = dev_get_drvdata(&pdev->dev);
> -
> -	spi_unregister_controller(master);
> -
> -	return 0;
> +	return devm_spi_register_controller(&pdev->dev, master);
>   }
>   
>   MODULE_ALIAS("platform:" DRIVER_NAME);
> @@ -397,7 +384,6 @@ static struct platform_driver mt7621_spi_driver = {
>   		.of_match_table = mt7621_spi_match,
>   	},
>   	.probe = mt7621_spi_probe,
> -	.remove = mt7621_spi_remove,
>   };
>   
>   module_platform_driver(mt7621_spi_driver);
diff mbox series

Patch

diff --git a/drivers/spi/spi-mt7621.c b/drivers/spi/spi-mt7621.c
index 2580b28042be..114f98dcae5e 100644
--- a/drivers/spi/spi-mt7621.c
+++ b/drivers/spi/spi-mt7621.c
@@ -373,20 +373,7 @@  static int mt7621_spi_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	ret = spi_register_controller(master);
-
-	return ret;
-}
-
-static int mt7621_spi_remove(struct platform_device *pdev)
-{
-	struct spi_controller *master;
-
-	master = dev_get_drvdata(&pdev->dev);
-
-	spi_unregister_controller(master);
-
-	return 0;
+	return devm_spi_register_controller(&pdev->dev, master);
 }
 
 MODULE_ALIAS("platform:" DRIVER_NAME);
@@ -397,7 +384,6 @@  static struct platform_driver mt7621_spi_driver = {
 		.of_match_table = mt7621_spi_match,
 	},
 	.probe = mt7621_spi_probe,
-	.remove = mt7621_spi_remove,
 };
 
 module_platform_driver(mt7621_spi_driver);