[ARM] 3250/1: Change pxa2xx PCMCIA drivers to use platform_device_alloc

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>

authored by Richard Purdie and committed by Russell King b016450f 49978db4

+12 -22
+5 -10
drivers/pcmcia/pxa2xx_mainstone.c
··· 171 { 172 int ret; 173 174 - mst_pcmcia_device = kzalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL); 175 if (!mst_pcmcia_device) 176 return -ENOMEM; 177 - mst_pcmcia_device->name = "pxa2xx-pcmcia"; 178 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; 179 180 - ret = platform_device_register(mst_pcmcia_device); 181 if (ret) 182 - kfree(mst_pcmcia_device); 183 184 return ret; 185 } 186 187 static void __exit mst_pcmcia_exit(void) 188 { 189 - /* 190 - * This call is supposed to free our mst_pcmcia_device. 191 - * Unfortunately platform_device don't have a free method, and 192 - * we can't assume it's free of any reference at this point so we 193 - * can't free it either. 194 - */ 195 platform_device_unregister(mst_pcmcia_device); 196 } 197
··· 171 { 172 int ret; 173 174 + mst_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 175 if (!mst_pcmcia_device) 176 return -ENOMEM; 177 + 178 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; 179 180 + ret = platform_device_add(mst_pcmcia_device); 181 + 182 if (ret) 183 + platform_device_put(mst_pcmcia_device); 184 185 return ret; 186 } 187 188 static void __exit mst_pcmcia_exit(void) 189 { 190 platform_device_unregister(mst_pcmcia_device); 191 } 192
+7 -12
drivers/pcmcia/pxa2xx_sharpsl.c
··· 263 { 264 int ret; 265 266 - sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs; 267 - sharpsl_pcmcia_device = kzalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); 268 if (!sharpsl_pcmcia_device) 269 return -ENOMEM; 270 271 - sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; 272 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 273 - sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev; 274 275 - ret = platform_device_register(sharpsl_pcmcia_device); 276 if (ret) 277 - kfree(sharpsl_pcmcia_device); 278 279 return ret; 280 } 281 282 static void __exit sharpsl_pcmcia_exit(void) 283 { 284 - /* 285 - * This call is supposed to free our sharpsl_pcmcia_device. 286 - * Unfortunately platform_device don't have a free method, and 287 - * we can't assume it's free of any reference at this point so we 288 - * can't free it either. 289 - */ 290 platform_device_unregister(sharpsl_pcmcia_device); 291 } 292
··· 263 { 264 int ret; 265 266 + sharpsl_pcmcia_ops.nr = platform_scoop_config->num_devs; 267 + sharpsl_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 268 + 269 if (!sharpsl_pcmcia_device) 270 return -ENOMEM; 271 272 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 273 + sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev; 274 275 + ret = platform_device_add(sharpsl_pcmcia_device); 276 + 277 if (ret) 278 + platform_device_put(sharpsl_pcmcia_device); 279 280 return ret; 281 } 282 283 static void __exit sharpsl_pcmcia_exit(void) 284 { 285 platform_device_unregister(sharpsl_pcmcia_device); 286 } 287