Merge branch 'urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[linux-2.6-block.git] / drivers / pcmcia / ds.c
index 0f98be4450b7a0e01a31e90542011bf46f47a4b2..cb6036d89e598e79d01ce5dc7f4256dc361ee068 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/firmware.h>
 #include <linux/kref.h>
 #include <linux/dma-mapping.h>
+#include <linux/slab.h>
 
 #include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
@@ -509,8 +510,12 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
        p_dev->device_no = (s->device_count++);
        mutex_unlock(&s->ops_mutex);
 
-       /* max of 2 devices per card */
-       if (p_dev->device_no >= 2)
+       /* max of 2 PFC devices */
+       if ((p_dev->device_no >= 2) && (function == 0))
+               goto err_free;
+
+       /* max of 4 devices overall */
+       if (p_dev->device_no >= 4)
                goto err_free;
 
        p_dev->socket = s;
@@ -971,9 +976,9 @@ static int runtime_suspend(struct device *dev)
 {
        int rc;
 
-       down(&dev->sem);
+       device_lock(dev);
        rc = pcmcia_dev_suspend(dev, PMSG_SUSPEND);
-       up(&dev->sem);
+       device_unlock(dev);
        return rc;
 }
 
@@ -981,9 +986,9 @@ static int runtime_resume(struct device *dev)
 {
        int rc;
 
-       down(&dev->sem);
+       device_lock(dev);
        rc = pcmcia_dev_resume(dev);
-       up(&dev->sem);
+       device_unlock(dev);
        return rc;
 }