Skip to content

Commit

Permalink
spi: s3c24xx: Convert to use devm_kzalloc
Browse files Browse the repository at this point in the history
Simplify the cleanup code.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Axel Lin authored and Mark Brown committed Apr 14, 2014
1 parent c9eaa44 commit c586feb
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions drivers/spi/spi-s3c24xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit c586feb

Please sign in to comment.