]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
spi: fsl: Kill mpc8xxx_spi_cleanup and convert fsl_espi_setup to use devm_kzalloc
authorAxel Lin <axel.lin@ingics.com>
Sun, 30 Mar 2014 08:43:23 +0000 (16:43 +0800)
committerMark Brown <broonie@linaro.org>
Mon, 14 Apr 2014 16:18:55 +0000 (17:18 +0100)
In current code, master->cleanup and master->setup are not set in the same
function. This makes it hard to read and not good for code maintain.
One example is in fsl-spi.c, master->cleanup is overrided in mpc8xxx_spi_probe()
which leads to a memory leak.

This patch removes mpc8xxx_spi_cleanup() and converts fsl_espi_setup to use
devm_kzalloc so we don't need to take care of freeing memory.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-fsl-espi.c
drivers/spi/spi-fsl-lib.c
drivers/spi/spi-fsl-lib.h

index e767f5831b9c7ce3d8ce015e34e67643f69a28df..3cf7d65bc739d67142a024071f98faa1dfbde86b 100644 (file)
@@ -458,7 +458,7 @@ static int fsl_espi_setup(struct spi_device *spi)
                return -EINVAL;
 
        if (!cs) {
-               cs = kzalloc(sizeof *cs, GFP_KERNEL);
+               cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL);
                if (!cs)
                        return -ENOMEM;
                spi->controller_state = cs;
index e5d45fca355182809ea9c3f66c63c1beef44ffdd..95212ea96c8dc07dff0599730e3e525368873a27 100644 (file)
@@ -99,11 +99,6 @@ int mpc8xxx_spi_transfer(struct spi_device *spi,
        return 0;
 }
 
-void mpc8xxx_spi_cleanup(struct spi_device *spi)
-{
-       kfree(spi->controller_state);
-}
-
 const char *mpc8xxx_spi_strmode(unsigned int flags)
 {
        if (flags & SPI_QE_CPU_MODE) {
@@ -134,7 +129,6 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
                        | SPI_LSB_FIRST | SPI_LOOP;
 
        master->transfer = mpc8xxx_spi_transfer;
-       master->cleanup = mpc8xxx_spi_cleanup;
        master->dev.of_node = dev->of_node;
 
        mpc8xxx_spi = spi_master_get_devdata(master);
index 52db6936778e70fbcb5aca72fb7dd3ab6078b386..2fcbfd01d1094402cd98cb459929ad6ba8f9bf71 100644 (file)
@@ -124,7 +124,6 @@ extern struct mpc8xxx_spi_probe_info *to_of_pinfo(
 extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi,
                struct spi_transfer *t, unsigned int len);
 extern int mpc8xxx_spi_transfer(struct spi_device *spi, struct spi_message *m);
-extern void mpc8xxx_spi_cleanup(struct spi_device *spi);
 extern const char *mpc8xxx_spi_strmode(unsigned int flags);
 extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem,
                unsigned int irq);