pcmcia: sa11x0: convert memory allocation to devm_* API
authorRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 26 Mar 2015 10:33:16 +0000 (10:33 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 8 Jul 2015 10:29:56 +0000 (11:29 +0100)
Convert the sa11x0 socket driver memory allocation to use devm_kzalloc()
to simplify the cleanup path.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/pcmcia/sa1100_generic.c
drivers/pcmcia/sa11xx_base.c

index 42861cc70158059e07a73afb7109a19fb5877ee7..66acdc85727cced33b7696f2d66c54ed14326e81 100644 (file)
@@ -93,7 +93,6 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
        for (i = 0; i < sinfo->nskt; i++)
                soc_pcmcia_remove_one(&sinfo->skt[i]);
 
-       kfree(sinfo);
        return 0;
 }
 
index 553d70a67f808fa17d4e0ed3e561208c0a2fd41f..6e6336d47d4ac54b7271669ec5ab36be97adf44c 100644 (file)
@@ -228,7 +228,7 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
 
        sa11xx_drv_pcmcia_ops(ops);
 
-       sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
+       sinfo = devm_kzalloc(dev, SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
        if (!sinfo)
                return -ENOMEM;
 
@@ -251,7 +251,6 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
        if (ret) {
                while (--i >= 0)
                        soc_pcmcia_remove_one(&sinfo->skt[i]);
-               kfree(sinfo);
        } else {
                dev_set_drvdata(dev, sinfo);
        }