[ARM] 3250/1: Change pxa2xx PCMCIA drivers to use platform_device_alloc
authorRichard Purdie <rpurdie@rpsys.net>
Tue, 10 Jan 2006 17:16:12 +0000 (17:16 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 10 Jan 2006 17:16:12 +0000 (17:16 +0000)
Patch from Richard Purdie

Change mainstone and sharpsl pxa2xx pcmcia drivers to use
platform_device_alloc which fixes a memory leak.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
drivers/pcmcia/pxa2xx_mainstone.c
drivers/pcmcia/pxa2xx_sharpsl.c

index 5d957dfe23d942f37c6851a2fdc963e9eff7f64e..fda06941e73062cdf9a6629dc9452153cf69f6b3 100644 (file)
@@ -171,27 +171,22 @@ static int __init mst_pcmcia_init(void)
 {
        int ret;
 
-       mst_pcmcia_device = kzalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL);
+       mst_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
        if (!mst_pcmcia_device)
                return -ENOMEM;
-       mst_pcmcia_device->name = "pxa2xx-pcmcia";
+
        mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops;
 
-       ret = platform_device_register(mst_pcmcia_device);
+       ret = platform_device_add(mst_pcmcia_device);
+
        if (ret)
-               kfree(mst_pcmcia_device);
+               platform_device_put(mst_pcmcia_device);
 
        return ret;
 }
 
 static void __exit mst_pcmcia_exit(void)
 {
-       /*
-        * This call is supposed to free our mst_pcmcia_device.
-        * Unfortunately platform_device don't have a free method, and
-        * we can't assume it's free of any reference at this point so we
-        * can't free it either.
-        */
        platform_device_unregister(mst_pcmcia_device);
 }
 
index 12a7244a5ec86e4a92bfca58f422c7d4c7c69511..fd3647368955f1f68aa8dad0f99ed25994b8ed15 100644 (file)
@@ -263,30 +263,25 @@ static int __init sharpsl_pcmcia_init(void)
 {
        int ret;
 
-       sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs;
-       sharpsl_pcmcia_device = kzalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
+       sharpsl_pcmcia_ops.nr = platform_scoop_config->num_devs;
+       sharpsl_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
+
        if (!sharpsl_pcmcia_device)
                return -ENOMEM;
 
-       sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
        sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
-       sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev;
+       sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
+
+       ret = platform_device_add(sharpsl_pcmcia_device);
 
-       ret = platform_device_register(sharpsl_pcmcia_device);
        if (ret)
-               kfree(sharpsl_pcmcia_device);
+               platform_device_put(sharpsl_pcmcia_device);
 
        return ret;
 }
 
 static void __exit sharpsl_pcmcia_exit(void)
 {
-       /*
-        * This call is supposed to free our sharpsl_pcmcia_device.
-        * Unfortunately platform_device don't have a free method, and
-        * we can't assume it's free of any reference at this point so we
-        * can't free it either.
-        */
        platform_device_unregister(sharpsl_pcmcia_device);
 }