mfd: Allow the platform to specify the sh_mobile_sdhi get_cd handler
[linux-2.6-block.git] / drivers / mfd / ezx-pcap.c
index 134c69aa47909142c20a292e61c56ed65267eaf0..d283d77937b9a8fed636100800c418e2f61c6f22 100644 (file)
@@ -384,12 +384,20 @@ static int __devinit pcap_add_subdev(struct pcap_chip *pcap,
                                                struct pcap_subdev *subdev)
 {
        struct platform_device *pdev;
+       int ret;
 
        pdev = platform_device_alloc(subdev->name, subdev->id);
+       if (!pdev)
+               return -ENOMEM;
+
        pdev->dev.parent = &pcap->spi->dev;
        pdev->dev.platform_data = subdev->platform_data;
 
-       return platform_device_add(pdev);
+       ret = platform_device_add(pdev);
+       if (ret)
+               platform_device_put(pdev);
+
+       return ret;
 }
 
 static int __devexit ezx_pcap_remove(struct spi_device *spi)