summaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pxa2xx_sharpsl.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2008-04-24 15:28:11 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-06-02 13:49:16 +0100
commit4e5e8de0dbdeb08df2b4c15fa2b0ba2216091793 (patch)
treecda179e4e8e7eaf1984f90638fba143b6dd8b228 /drivers/pcmcia/pxa2xx_sharpsl.c
parent04ba0f656f7580d8a51a5b3441e088309141b67a (diff)
downloadtalos-op-linux-4e5e8de0dbdeb08df2b4c15fa2b0ba2216091793.tar.gz
talos-op-linux-4e5e8de0dbdeb08df2b4c15fa2b0ba2216091793.zip
[ARM] pxa: avoid kfreeing static data if platform device fails to register
When a dynamically allocated platform device is 'put', the platform device's platform_data is kfree'd. This is bad if it's pointing at static data. Use the provided function to register platform data for these devices. This also means we can mark the pcmcia ops structures as __initdata. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'drivers/pcmcia/pxa2xx_sharpsl.c')
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index d5c33bd78d68..d71f93d45833 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -222,7 +222,7 @@ static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
sharpsl_pcmcia_init_reset(skt);
}
-static struct pcmcia_low_level sharpsl_pcmcia_ops = {
+static struct pcmcia_low_level sharpsl_pcmcia_ops __initdata = {
.owner = THIS_MODULE,
.hw_init = sharpsl_pcmcia_hw_init,
.hw_shutdown = sharpsl_pcmcia_hw_shutdown,
@@ -261,10 +261,12 @@ static int __init sharpsl_pcmcia_init(void)
if (!sharpsl_pcmcia_device)
return -ENOMEM;
- sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
- sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
-
- ret = platform_device_add(sharpsl_pcmcia_device);
+ ret = platform_device_add_data(sharpsl_pcmcia_device,
+ &sharpsl_pcmcia_ops, sizeof(sharpsl_pcmcia_ops));
+ if (ret == 0) {
+ sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
+ ret = platform_device_add(sharpsl_pcmcia_device);
+ }
if (ret)
platform_device_put(sharpsl_pcmcia_device);
OpenPOWER on IntegriCloud