diff mbox

spi: s3c24xx: Convert to use devm_kzalloc

Message ID 1396237049.12196.1.camel@phoenix (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Axel Lin March 31, 2014, 3:37 a.m. UTC
Simplify the cleanup code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/spi/spi-s3c24xx.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Jingoo Han April 1, 2014, 2:02 a.m. UTC | #1
On Monday, March 31, 2014 12:37 PM, Axel Lin wrote:
> 
> Simplify the cleanup code.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Reviewed-by: Jingoo Han <jg1.han@samsung.com>

Best regards,
Jingoo Han

> ---
>  drivers/spi/spi-s3c24xx.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
> index bed2338..6db14e5 100644
> --- a/drivers/spi/spi-s3c24xx.c
> +++ b/drivers/spi/spi-s3c24xx.c
> @@ -183,7 +183,9 @@ static int s3c24xx_spi_setup(struct spi_device *spi)
> 
>  	/* allocate settings on the first call */
>  	if (!cs) {
> -		cs = kzalloc(sizeof(struct s3c24xx_spi_devstate), GFP_KERNEL);
> +		cs = devm_kzalloc(&spi->dev,
> +				  sizeof(struct s3c24xx_spi_devstate),
> +				  GFP_KERNEL);
>  		if (!cs) {
>  			dev_err(&spi->dev, "no memory for controller state\n");
>  			return -ENOMEM;
> @@ -209,11 +211,6 @@ static int s3c24xx_spi_setup(struct spi_device *spi)
>  	return 0;
>  }
> 
> -static void s3c24xx_spi_cleanup(struct spi_device *spi)
> -{
> -	kfree(spi->controller_state);
> -}
> -
>  static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count)
>  {
>  	return hw->tx ? hw->tx[count] : 0;
> @@ -543,7 +540,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
>  	hw->bitbang.txrx_bufs      = s3c24xx_spi_txrx;
> 
>  	hw->master->setup  = s3c24xx_spi_setup;
> -	hw->master->cleanup = s3c24xx_spi_cleanup;
> 
>  	dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
> 
> --
> 1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown April 1, 2014, 11:10 a.m. UTC | #2
On Mon, Mar 31, 2014 at 11:37:29AM +0800, Axel Lin wrote:
> Simplify the cleanup code.

Applied, thanks.
Ben Dooks April 3, 2014, 1:26 p.m. UTC | #3
On Mon, Mar 31, 2014 at 11:37:29AM +0800, Axel Lin wrote:
> Simplify the cleanup code.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Ben Dooks <ben-linux@fluff.org>
> ---
>  drivers/spi/spi-s3c24xx.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
> index bed2338..6db14e5 100644
> --- a/drivers/spi/spi-s3c24xx.c
> +++ b/drivers/spi/spi-s3c24xx.c
> @@ -183,7 +183,9 @@ static int s3c24xx_spi_setup(struct spi_device *spi)
>  
>  	/* allocate settings on the first call */
>  	if (!cs) {
> -		cs = kzalloc(sizeof(struct s3c24xx_spi_devstate), GFP_KERNEL);
> +		cs = devm_kzalloc(&spi->dev,
> +				  sizeof(struct s3c24xx_spi_devstate),
> +				  GFP_KERNEL);
>  		if (!cs) {
>  			dev_err(&spi->dev, "no memory for controller state\n");
>  			return -ENOMEM;
> @@ -209,11 +211,6 @@ static int s3c24xx_spi_setup(struct spi_device *spi)
>  	return 0;
>  }
>  
> -static void s3c24xx_spi_cleanup(struct spi_device *spi)
> -{
> -	kfree(spi->controller_state);
> -}
> -
>  static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count)
>  {
>  	return hw->tx ? hw->tx[count] : 0;
> @@ -543,7 +540,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev)
>  	hw->bitbang.txrx_bufs      = s3c24xx_spi_txrx;
>  
>  	hw->master->setup  = s3c24xx_spi_setup;
> -	hw->master->cleanup = s3c24xx_spi_cleanup;
>  
>  	dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);
>  
> -- 
> 1.8.3.2
> 
> 
>
diff mbox

Patch

diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c
index bed2338..6db14e5 100644
--- a/drivers/spi/spi-s3c24xx.c
+++ b/drivers/spi/spi-s3c24xx.c
@@ -183,7 +183,9 @@  static int s3c24xx_spi_setup(struct spi_device *spi)
 
 	/* allocate settings on the first call */
 	if (!cs) {
-		cs = kzalloc(sizeof(struct s3c24xx_spi_devstate), GFP_KERNEL);
+		cs = devm_kzalloc(&spi->dev,
+				  sizeof(struct s3c24xx_spi_devstate),
+				  GFP_KERNEL);
 		if (!cs) {
 			dev_err(&spi->dev, "no memory for controller state\n");
 			return -ENOMEM;
@@ -209,11 +211,6 @@  static int s3c24xx_spi_setup(struct spi_device *spi)
 	return 0;
 }
 
-static void s3c24xx_spi_cleanup(struct spi_device *spi)
-{
-	kfree(spi->controller_state);
-}
-
 static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count)
 {
 	return hw->tx ? hw->tx[count] : 0;
@@ -543,7 +540,6 @@  static int s3c24xx_spi_probe(struct platform_device *pdev)
 	hw->bitbang.txrx_bufs      = s3c24xx_spi_txrx;
 
 	hw->master->setup  = s3c24xx_spi_setup;
-	hw->master->cleanup = s3c24xx_spi_cleanup;
 
 	dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);