aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/at91_cf.c3
-rw-r--r--drivers/pcmcia/au1000_generic.c14
-rw-r--r--drivers/pcmcia/bcm63xx_pcmcia.c1
-rw-r--r--drivers/pcmcia/bfin_cf_pcmcia.c13
-rw-r--r--drivers/pcmcia/cistpl.c9
-rw-r--r--drivers/pcmcia/cs.c140
-rw-r--r--drivers/pcmcia/db1xxx_ss.c40
-rw-r--r--drivers/pcmcia/ds.c86
-rw-r--r--drivers/pcmcia/electra_cf.c1
-rw-r--r--drivers/pcmcia/i82092.c16
-rw-r--r--drivers/pcmcia/i82365.c12
-rw-r--r--drivers/pcmcia/m32r_cfc.c12
-rw-r--r--drivers/pcmcia/m32r_pcc.c13
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c18
-rw-r--r--drivers/pcmcia/omap_cf.c13
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c8
-rw-r--r--drivers/pcmcia/pcmcia_resource.c11
-rw-r--r--drivers/pcmcia/pd6729.c81
-rw-r--r--drivers/pcmcia/pxa2xx_base.c9
-rw-r--r--drivers/pcmcia/rsrc_mgr.c1
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c66
-rw-r--r--drivers/pcmcia/sa1100_generic.c14
-rw-r--r--drivers/pcmcia/sa1111_generic.c13
-rw-r--r--drivers/pcmcia/sa11xx_base.c1
-rw-r--r--drivers/pcmcia/socket_sysfs.c1
-rw-r--r--drivers/pcmcia/tcic.c13
-rw-r--r--drivers/pcmcia/vrc4171_card.c13
-rw-r--r--drivers/pcmcia/xxs1500_ss.c1
-rw-r--r--drivers/pcmcia/yenta_socket.c18
29 files changed, 224 insertions, 417 deletions
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 5d228071ec69..fb33fa42d249 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -15,6 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/slab.h>
18 19
19#include <pcmcia/ss.h> 20#include <pcmcia/ss.h>
20 21
@@ -361,7 +362,6 @@ static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
361 struct at91_cf_socket *cf = platform_get_drvdata(pdev); 362 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
362 struct at91_cf_data *board = cf->board; 363 struct at91_cf_data *board = cf->board;
363 364
364 pcmcia_socket_dev_suspend(&pdev->dev);
365 if (device_may_wakeup(&pdev->dev)) { 365 if (device_may_wakeup(&pdev->dev)) {
366 enable_irq_wake(board->det_pin); 366 enable_irq_wake(board->det_pin);
367 if (board->irq_pin) 367 if (board->irq_pin)
@@ -381,7 +381,6 @@ static int at91_cf_resume(struct platform_device *pdev)
381 disable_irq_wake(board->irq_pin); 381 disable_irq_wake(board->irq_pin);
382 } 382 }
383 383
384 pcmcia_socket_dev_resume(&pdev->dev);
385 return 0; 384 return 0;
386} 385}
387 386
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 171c8a654887..88c4c4098789 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -43,6 +43,7 @@
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/mutex.h> 44#include <linux/mutex.h>
45#include <linux/platform_device.h> 45#include <linux/platform_device.h>
46#include <linux/slab.h>
46 47
47#include <asm/io.h> 48#include <asm/io.h>
48#include <asm/irq.h> 49#include <asm/irq.h>
@@ -510,17 +511,6 @@ static int au1x00_drv_pcmcia_probe(struct platform_device *dev)
510 return ret; 511 return ret;
511} 512}
512 513
513static int au1x00_drv_pcmcia_suspend(struct platform_device *dev,
514 pm_message_t state)
515{
516 return pcmcia_socket_dev_suspend(&dev->dev);
517}
518
519static int au1x00_drv_pcmcia_resume(struct platform_device *dev)
520{
521 return pcmcia_socket_dev_resume(&dev->dev);
522}
523
524static struct platform_driver au1x00_pcmcia_driver = { 514static struct platform_driver au1x00_pcmcia_driver = {
525 .driver = { 515 .driver = {
526 .name = "au1x00-pcmcia", 516 .name = "au1x00-pcmcia",
@@ -528,8 +518,6 @@ static struct platform_driver au1x00_pcmcia_driver = {
528 }, 518 },
529 .probe = au1x00_drv_pcmcia_probe, 519 .probe = au1x00_drv_pcmcia_probe,
530 .remove = au1x00_drv_pcmcia_remove, 520 .remove = au1x00_drv_pcmcia_remove,
531 .suspend = au1x00_drv_pcmcia_suspend,
532 .resume = au1x00_drv_pcmcia_resume,
533}; 521};
534 522
535 523
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
index bc88a3b19bb3..693577e0fefc 100644
--- a/drivers/pcmcia/bcm63xx_pcmcia.c
+++ b/drivers/pcmcia/bcm63xx_pcmcia.c
@@ -11,6 +11,7 @@
11#include <linux/ioport.h> 11#include <linux/ioport.h>
12#include <linux/timer.h> 12#include <linux/timer.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/slab.h>
14#include <linux/delay.h> 15#include <linux/delay.h>
15#include <linux/pci.h> 16#include <linux/pci.h>
16#include <linux/gpio.h> 17#include <linux/gpio.h>
diff --git a/drivers/pcmcia/bfin_cf_pcmcia.c b/drivers/pcmcia/bfin_cf_pcmcia.c
index 2482ce7ac6dc..9e84d039de41 100644
--- a/drivers/pcmcia/bfin_cf_pcmcia.c
+++ b/drivers/pcmcia/bfin_cf_pcmcia.c
@@ -31,6 +31,7 @@
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/slab.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/interrupt.h> 36#include <linux/interrupt.h>
36#include <linux/irq.h> 37#include <linux/irq.h>
@@ -300,16 +301,6 @@ static int __devexit bfin_cf_remove(struct platform_device *pdev)
300 return 0; 301 return 0;
301} 302}
302 303
303static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
304{
305 return pcmcia_socket_dev_suspend(&pdev->dev);
306}
307
308static int bfin_cf_resume(struct platform_device *pdev)
309{
310 return pcmcia_socket_dev_resume(&pdev->dev);
311}
312
313static struct platform_driver bfin_cf_driver = { 304static struct platform_driver bfin_cf_driver = {
314 .driver = { 305 .driver = {
315 .name = (char *)driver_name, 306 .name = (char *)driver_name,
@@ -317,8 +308,6 @@ static struct platform_driver bfin_cf_driver = {
317 }, 308 },
318 .probe = bfin_cf_probe, 309 .probe = bfin_cf_probe,
319 .remove = __devexit_p(bfin_cf_remove), 310 .remove = __devexit_p(bfin_cf_remove),
320 .suspend = bfin_cf_suspend,
321 .resume = bfin_cf_resume,
322}; 311};
323 312
324static int __init bfin_cf_init(void) 313static int __init bfin_cf_init(void)
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index f230f6543bff..854959cada3a 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -1484,6 +1484,11 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *info)
1484 if (!s) 1484 if (!s)
1485 return -EINVAL; 1485 return -EINVAL;
1486 1486
1487 if (s->functions) {
1488 WARN_ON(1);
1489 return -EINVAL;
1490 }
1491
1487 /* We do not want to validate the CIS cache... */ 1492 /* We do not want to validate the CIS cache... */
1488 mutex_lock(&s->ops_mutex); 1493 mutex_lock(&s->ops_mutex);
1489 destroy_cis_cache(s); 1494 destroy_cis_cache(s);
@@ -1639,7 +1644,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
1639 count = 0; 1644 count = 0;
1640 else { 1645 else {
1641 struct pcmcia_socket *s; 1646 struct pcmcia_socket *s;
1642 unsigned int chains; 1647 unsigned int chains = 1;
1643 1648
1644 if (off + count > size) 1649 if (off + count > size)
1645 count = size - off; 1650 count = size - off;
@@ -1648,7 +1653,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
1648 1653
1649 if (!(s->state & SOCKET_PRESENT)) 1654 if (!(s->state & SOCKET_PRESENT))
1650 return -ENODEV; 1655 return -ENODEV;
1651 if (pccard_validate_cis(s, &chains)) 1656 if (!s->functions && pccard_validate_cis(s, &chains))
1652 return -EIO; 1657 return -EIO;
1653 if (!chains) 1658 if (!chains)
1654 return -ENODATA; 1659 return -ENODATA;
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index e679e708db63..c3383750e333 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -76,65 +76,6 @@ DECLARE_RWSEM(pcmcia_socket_list_rwsem);
76EXPORT_SYMBOL(pcmcia_socket_list_rwsem); 76EXPORT_SYMBOL(pcmcia_socket_list_rwsem);
77 77
78 78
79/*
80 * Low-level PCMCIA socket drivers need to register with the PCCard
81 * core using pcmcia_register_socket.
82 *
83 * socket drivers are expected to use the following callbacks in their
84 * .drv struct:
85 * - pcmcia_socket_dev_suspend
86 * - pcmcia_socket_dev_resume
87 * These functions check for the appropriate struct pcmcia_soket arrays,
88 * and pass them to the low-level functions pcmcia_{suspend,resume}_socket
89 */
90static int socket_early_resume(struct pcmcia_socket *skt);
91static int socket_late_resume(struct pcmcia_socket *skt);
92static int socket_resume(struct pcmcia_socket *skt);
93static int socket_suspend(struct pcmcia_socket *skt);
94
95static void pcmcia_socket_dev_run(struct device *dev,
96 int (*cb)(struct pcmcia_socket *))
97{
98 struct pcmcia_socket *socket;
99
100 down_read(&pcmcia_socket_list_rwsem);
101 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) {
102 if (socket->dev.parent != dev)
103 continue;
104 mutex_lock(&socket->skt_mutex);
105 cb(socket);
106 mutex_unlock(&socket->skt_mutex);
107 }
108 up_read(&pcmcia_socket_list_rwsem);
109}
110
111int pcmcia_socket_dev_suspend(struct device *dev)
112{
113 pcmcia_socket_dev_run(dev, socket_suspend);
114 return 0;
115}
116EXPORT_SYMBOL(pcmcia_socket_dev_suspend);
117
118void pcmcia_socket_dev_early_resume(struct device *dev)
119{
120 pcmcia_socket_dev_run(dev, socket_early_resume);
121}
122EXPORT_SYMBOL(pcmcia_socket_dev_early_resume);
123
124void pcmcia_socket_dev_late_resume(struct device *dev)
125{
126 pcmcia_socket_dev_run(dev, socket_late_resume);
127}
128EXPORT_SYMBOL(pcmcia_socket_dev_late_resume);
129
130int pcmcia_socket_dev_resume(struct device *dev)
131{
132 pcmcia_socket_dev_run(dev, socket_resume);
133 return 0;
134}
135EXPORT_SYMBOL(pcmcia_socket_dev_resume);
136
137
138struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt) 79struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt)
139{ 80{
140 struct device *dev = get_device(&skt->dev); 81 struct device *dev = get_device(&skt->dev);
@@ -578,12 +519,18 @@ static int socket_early_resume(struct pcmcia_socket *skt)
578 519
579static int socket_late_resume(struct pcmcia_socket *skt) 520static int socket_late_resume(struct pcmcia_socket *skt)
580{ 521{
522 int ret;
523
581 mutex_lock(&skt->ops_mutex); 524 mutex_lock(&skt->ops_mutex);
582 skt->state &= ~SOCKET_SUSPEND; 525 skt->state &= ~SOCKET_SUSPEND;
583 mutex_unlock(&skt->ops_mutex); 526 mutex_unlock(&skt->ops_mutex);
584 527
585 if (!(skt->state & SOCKET_PRESENT)) 528 if (!(skt->state & SOCKET_PRESENT)) {
586 return socket_insert(skt); 529 ret = socket_insert(skt);
530 if (ret == -ENODEV)
531 ret = 0;
532 return ret;
533 }
587 534
588 if (skt->resume_status) { 535 if (skt->resume_status) {
589 socket_shutdown(skt); 536 socket_shutdown(skt);
@@ -724,20 +671,22 @@ static int pccardd(void *__skt)
724 socket_remove(skt); 671 socket_remove(skt);
725 if (sysfs_events & PCMCIA_UEVENT_INSERT) 672 if (sysfs_events & PCMCIA_UEVENT_INSERT)
726 socket_insert(skt); 673 socket_insert(skt);
727 if ((sysfs_events & PCMCIA_UEVENT_RESUME) &&
728 !(skt->state & SOCKET_CARDBUS)) {
729 ret = socket_resume(skt);
730 if (!ret && skt->callback)
731 skt->callback->resume(skt);
732 }
733 if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) && 674 if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) &&
734 !(skt->state & SOCKET_CARDBUS)) { 675 !(skt->state & SOCKET_CARDBUS)) {
735 if (skt->callback) 676 if (skt->callback)
736 ret = skt->callback->suspend(skt); 677 ret = skt->callback->suspend(skt);
737 else 678 else
738 ret = 0; 679 ret = 0;
739 if (!ret) 680 if (!ret) {
740 socket_suspend(skt); 681 socket_suspend(skt);
682 msleep(100);
683 }
684 }
685 if ((sysfs_events & PCMCIA_UEVENT_RESUME) &&
686 !(skt->state & SOCKET_CARDBUS)) {
687 ret = socket_resume(skt);
688 if (!ret && skt->callback)
689 skt->callback->resume(skt);
741 } 690 }
742 if ((sysfs_events & PCMCIA_UEVENT_REQUERY) && 691 if ((sysfs_events & PCMCIA_UEVENT_REQUERY) &&
743 !(skt->state & SOCKET_CARDBUS)) { 692 !(skt->state & SOCKET_CARDBUS)) {
@@ -919,11 +868,66 @@ static void pcmcia_release_socket_class(struct class *data)
919} 868}
920 869
921 870
871#ifdef CONFIG_PM
872
873static int __pcmcia_pm_op(struct device *dev,
874 int (*callback) (struct pcmcia_socket *skt))
875{
876 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
877 int ret;
878
879 mutex_lock(&s->skt_mutex);
880 ret = callback(s);
881 mutex_unlock(&s->skt_mutex);
882
883 return ret;
884}
885
886static int pcmcia_socket_dev_suspend_noirq(struct device *dev)
887{
888 return __pcmcia_pm_op(dev, socket_suspend);
889}
890
891static int pcmcia_socket_dev_resume_noirq(struct device *dev)
892{
893 return __pcmcia_pm_op(dev, socket_early_resume);
894}
895
896static int pcmcia_socket_dev_resume(struct device *dev)
897{
898 return __pcmcia_pm_op(dev, socket_late_resume);
899}
900
901static const struct dev_pm_ops pcmcia_socket_pm_ops = {
902 /* dev_resume may be called with IRQs enabled */
903 SET_SYSTEM_SLEEP_PM_OPS(NULL,
904 pcmcia_socket_dev_resume)
905
906 /* late suspend must be called with IRQs disabled */
907 .suspend_noirq = pcmcia_socket_dev_suspend_noirq,
908 .freeze_noirq = pcmcia_socket_dev_suspend_noirq,
909 .poweroff_noirq = pcmcia_socket_dev_suspend_noirq,
910
911 /* early resume must be called with IRQs disabled */
912 .resume_noirq = pcmcia_socket_dev_resume_noirq,
913 .thaw_noirq = pcmcia_socket_dev_resume_noirq,
914 .restore_noirq = pcmcia_socket_dev_resume_noirq,
915};
916
917#define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops)
918
919#else /* CONFIG_PM */
920
921#define PCMCIA_SOCKET_CLASS_PM_OPS NULL
922
923#endif /* CONFIG_PM */
924
922struct class pcmcia_socket_class = { 925struct class pcmcia_socket_class = {
923 .name = "pcmcia_socket", 926 .name = "pcmcia_socket",
924 .dev_uevent = pcmcia_socket_uevent, 927 .dev_uevent = pcmcia_socket_uevent,
925 .dev_release = pcmcia_release_socket, 928 .dev_release = pcmcia_release_socket,
926 .class_release = pcmcia_release_socket_class, 929 .class_release = pcmcia_release_socket_class,
930 .pm = PCMCIA_SOCKET_CLASS_PM_OPS,
927}; 931};
928EXPORT_SYMBOL(pcmcia_socket_class); 932EXPORT_SYMBOL(pcmcia_socket_class);
929 933
diff --git a/drivers/pcmcia/db1xxx_ss.c b/drivers/pcmcia/db1xxx_ss.c
index 9254ab0b29b1..0f4cc3f00028 100644
--- a/drivers/pcmcia/db1xxx_ss.c
+++ b/drivers/pcmcia/db1xxx_ss.c
@@ -26,6 +26,7 @@
26#include <linux/pm.h> 26#include <linux/pm.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/resource.h> 28#include <linux/resource.h>
29#include <linux/slab.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30 31
31#include <pcmcia/cs_types.h> 32#include <pcmcia/cs_types.h>
@@ -145,7 +146,6 @@ static irqreturn_t db1200_pcmcia_cdirq(int irq, void *data)
145static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock) 146static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
146{ 147{
147 int ret; 148 int ret;
148 unsigned long flags;
149 149
150 if (sock->stschg_irq != -1) { 150 if (sock->stschg_irq != -1) {
151 ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq, 151 ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq,
@@ -161,8 +161,6 @@ static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
161 * active one disabled. 161 * active one disabled.
162 */ 162 */
163 if (sock->board_type == BOARD_TYPE_DB1200) { 163 if (sock->board_type == BOARD_TYPE_DB1200) {
164 local_irq_save(flags);
165
166 ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq, 164 ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq,
167 IRQF_DISABLED, "pcmcia_insert", sock); 165 IRQF_DISABLED, "pcmcia_insert", sock);
168 if (ret) 166 if (ret)
@@ -172,17 +170,14 @@ static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
172 IRQF_DISABLED, "pcmcia_eject", sock); 170 IRQF_DISABLED, "pcmcia_eject", sock);
173 if (ret) { 171 if (ret) {
174 free_irq(sock->insert_irq, sock); 172 free_irq(sock->insert_irq, sock);
175 local_irq_restore(flags);
176 goto out1; 173 goto out1;
177 } 174 }
178 175
179 /* disable the currently active one */ 176 /* enable the currently silent one */
180 if (db1200_card_inserted(sock)) 177 if (db1200_card_inserted(sock))
181 disable_irq_nosync(sock->insert_irq); 178 enable_irq(sock->eject_irq);
182 else 179 else
183 disable_irq_nosync(sock->eject_irq); 180 enable_irq(sock->insert_irq);
184
185 local_irq_restore(flags);
186 } else { 181 } else {
187 /* all other (older) Db1x00 boards use a GPIO to show 182 /* all other (older) Db1x00 boards use a GPIO to show
188 * card detection status: use both-edge triggers. 183 * card detection status: use both-edge triggers.
@@ -558,37 +553,10 @@ static int __devexit db1x_pcmcia_socket_remove(struct platform_device *pdev)
558 return 0; 553 return 0;
559} 554}
560 555
561#ifdef CONFIG_PM
562static int db1x_pcmcia_suspend(struct device *dev)
563{
564 return pcmcia_socket_dev_suspend(dev);
565}
566
567static int db1x_pcmcia_resume(struct device *dev)
568{
569 return pcmcia_socket_dev_resume(dev);
570}
571
572static struct dev_pm_ops db1x_pcmcia_pmops = {
573 .resume = db1x_pcmcia_resume,
574 .suspend = db1x_pcmcia_suspend,
575 .thaw = db1x_pcmcia_resume,
576 .freeze = db1x_pcmcia_suspend,
577};
578
579#define DB1XXX_SS_PMOPS &db1x_pcmcia_pmops
580
581#else
582
583#define DB1XXX_SS_PMOPS NULL
584
585#endif
586
587static struct platform_driver db1x_pcmcia_socket_driver = { 556static struct platform_driver db1x_pcmcia_socket_driver = {
588 .driver = { 557 .driver = {
589 .name = "db1xxx_pcmcia", 558 .name = "db1xxx_pcmcia",
590 .owner = THIS_MODULE, 559 .owner = THIS_MODULE,
591 .pm = DB1XXX_SS_PMOPS
592 }, 560 },
593 .probe = db1x_pcmcia_socket_probe, 561 .probe = db1x_pcmcia_socket_probe,
594 .remove = __devexit_p(db1x_pcmcia_socket_remove), 562 .remove = __devexit_p(db1x_pcmcia_socket_remove),
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index ad93ebd7b2a2..041eee43fd8d 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -24,6 +24,7 @@
24#include <linux/firmware.h> 24#include <linux/firmware.h>
25#include <linux/kref.h> 25#include <linux/kref.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27#include <linux/slab.h>
27 28
28#include <pcmcia/cs_types.h> 29#include <pcmcia/cs_types.h>
29#include <pcmcia/cs.h> 30#include <pcmcia/cs.h>
@@ -334,7 +335,6 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
334 335
335 mutex_lock(&s->ops_mutex); 336 mutex_lock(&s->ops_mutex);
336 list_del(&p_dev->socket_device_list); 337 list_del(&p_dev->socket_device_list);
337 p_dev->_removed = 1;
338 mutex_unlock(&s->ops_mutex); 338 mutex_unlock(&s->ops_mutex);
339 339
340 dev_dbg(&p_dev->dev, "unregistering device\n"); 340 dev_dbg(&p_dev->dev, "unregistering device\n");
@@ -509,8 +509,12 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
509 p_dev->device_no = (s->device_count++); 509 p_dev->device_no = (s->device_count++);
510 mutex_unlock(&s->ops_mutex); 510 mutex_unlock(&s->ops_mutex);
511 511
512 /* max of 2 devices per card */ 512 /* max of 2 PFC devices */
513 if (p_dev->device_no >= 2) 513 if ((p_dev->device_no >= 2) && (function == 0))
514 goto err_free;
515
516 /* max of 4 devices overall */
517 if (p_dev->device_no >= 4)
514 goto err_free; 518 goto err_free;
515 519
516 p_dev->socket = s; 520 p_dev->socket = s;
@@ -649,14 +653,7 @@ static int pcmcia_requery_callback(struct device *dev, void * _data)
649 653
650static void pcmcia_requery(struct pcmcia_socket *s) 654static void pcmcia_requery(struct pcmcia_socket *s)
651{ 655{
652 int present, has_pfc; 656 int has_pfc;
653
654 mutex_lock(&s->ops_mutex);
655 present = s->pcmcia_state.present;
656 mutex_unlock(&s->ops_mutex);
657
658 if (!present)
659 return;
660 657
661 if (s->functions == 0) { 658 if (s->functions == 0) {
662 pcmcia_card_add(s); 659 pcmcia_card_add(s);
@@ -682,12 +679,10 @@ static void pcmcia_requery(struct pcmcia_socket *s)
682 new_funcs = mfc.nfn; 679 new_funcs = mfc.nfn;
683 else 680 else
684 new_funcs = 1; 681 new_funcs = 1;
685 if (old_funcs > new_funcs) { 682 if (old_funcs != new_funcs) {
683 /* we need to re-start */
686 pcmcia_card_remove(s, NULL); 684 pcmcia_card_remove(s, NULL);
687 pcmcia_card_add(s); 685 pcmcia_card_add(s);
688 } else if (new_funcs > old_funcs) {
689 s->functions = new_funcs;
690 pcmcia_device_add(s, 1);
691 } 686 }
692 } 687 }
693 688
@@ -723,6 +718,8 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
723 struct pcmcia_socket *s = dev->socket; 718 struct pcmcia_socket *s = dev->socket;
724 const struct firmware *fw; 719 const struct firmware *fw;
725 int ret = -ENOMEM; 720 int ret = -ENOMEM;
721 cistpl_longlink_mfc_t mfc;
722 int old_funcs, new_funcs = 1;
726 723
727 if (!filename) 724 if (!filename)
728 return -EINVAL; 725 return -EINVAL;
@@ -745,6 +742,14 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
745 goto release; 742 goto release;
746 } 743 }
747 744
745 /* we need to re-start if the number of functions changed */
746 old_funcs = s->functions;
747 if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC,
748 &mfc))
749 new_funcs = mfc.nfn;
750
751 if (old_funcs != new_funcs)
752 ret = -EBUSY;
748 753
749 /* update information */ 754 /* update information */
750 pcmcia_device_query(dev); 755 pcmcia_device_query(dev);
@@ -815,11 +820,12 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
815 } 820 }
816 821
817 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { 822 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) {
818 if (dev->device_no != did->device_no) 823 dev_dbg(&dev->dev, "this is a pseudo-multi-function device\n");
819 return 0;
820 mutex_lock(&dev->socket->ops_mutex); 824 mutex_lock(&dev->socket->ops_mutex);
821 dev->socket->pcmcia_state.has_pfc = 1; 825 dev->socket->pcmcia_state.has_pfc = 1;
822 mutex_unlock(&dev->socket->ops_mutex); 826 mutex_unlock(&dev->socket->ops_mutex);
827 if (dev->device_no != did->device_no)
828 return 0;
823 } 829 }
824 830
825 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { 831 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) {
@@ -830,7 +836,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
830 836
831 /* if this is a pseudo-multi-function device, 837 /* if this is a pseudo-multi-function device,
832 * we need explicit matches */ 838 * we need explicit matches */
833 if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) 839 if (dev->socket->pcmcia_state.has_pfc)
834 return 0; 840 return 0;
835 if (dev->device_no) 841 if (dev->device_no)
836 return 0; 842 return 0;
@@ -853,10 +859,8 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
853 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 859 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
854 dev_dbg(&dev->dev, "device needs a fake CIS\n"); 860 dev_dbg(&dev->dev, "device needs a fake CIS\n");
855 if (!dev->socket->fake_cis) 861 if (!dev->socket->fake_cis)
856 pcmcia_load_firmware(dev, did->cisfile); 862 if (pcmcia_load_firmware(dev, did->cisfile))
857 863 return 0;
858 if (!dev->socket->fake_cis)
859 return 0;
860 } 864 }
861 865
862 if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { 866 if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) {
@@ -1249,9 +1253,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1249 1253
1250 switch (event) { 1254 switch (event) {
1251 case CS_EVENT_CARD_REMOVAL: 1255 case CS_EVENT_CARD_REMOVAL:
1252 mutex_lock(&s->ops_mutex); 1256 atomic_set(&skt->present, 0);
1253 s->pcmcia_state.present = 0;
1254 mutex_unlock(&s->ops_mutex);
1255 pcmcia_card_remove(skt, NULL); 1257 pcmcia_card_remove(skt, NULL);
1256 handle_event(skt, event); 1258 handle_event(skt, event);
1257 mutex_lock(&s->ops_mutex); 1259 mutex_lock(&s->ops_mutex);
@@ -1260,9 +1262,9 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1260 break; 1262 break;
1261 1263
1262 case CS_EVENT_CARD_INSERTION: 1264 case CS_EVENT_CARD_INSERTION:
1265 atomic_set(&skt->present, 1);
1263 mutex_lock(&s->ops_mutex); 1266 mutex_lock(&s->ops_mutex);
1264 s->pcmcia_state.has_pfc = 0; 1267 s->pcmcia_state.has_pfc = 0;
1265 s->pcmcia_state.present = 1;
1266 destroy_cis_cache(s); /* to be on the safe side... */ 1268 destroy_cis_cache(s); /* to be on the safe side... */
1267 mutex_unlock(&s->ops_mutex); 1269 mutex_unlock(&s->ops_mutex);
1268 pcmcia_card_add(skt); 1270 pcmcia_card_add(skt);
@@ -1281,6 +1283,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1281 destroy_cis_cache(skt); 1283 destroy_cis_cache(skt);
1282 kfree(skt->fake_cis); 1284 kfree(skt->fake_cis);
1283 skt->fake_cis = NULL; 1285 skt->fake_cis = NULL;
1286 s->functions = 0;
1284 mutex_unlock(&s->ops_mutex); 1287 mutex_unlock(&s->ops_mutex);
1285 /* now, add the new card */ 1288 /* now, add the new card */
1286 ds_event(skt, CS_EVENT_CARD_INSERTION, 1289 ds_event(skt, CS_EVENT_CARD_INSERTION,
@@ -1302,7 +1305,13 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1302 return 0; 1305 return 0;
1303} /* ds_event */ 1306} /* ds_event */
1304 1307
1305 1308/*
1309 * NOTE: This is racy. There's no guarantee the card will still be
1310 * physically present, even if the call to this function returns
1311 * non-NULL. Furthermore, the device driver most likely is unbound
1312 * almost immediately, so the timeframe where pcmcia_dev_present
1313 * returns NULL is probably really really small.
1314 */
1306struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) 1315struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
1307{ 1316{
1308 struct pcmcia_device *p_dev; 1317 struct pcmcia_device *p_dev;
@@ -1312,22 +1321,9 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
1312 if (!p_dev) 1321 if (!p_dev)
1313 return NULL; 1322 return NULL;
1314 1323
1315 mutex_lock(&p_dev->socket->ops_mutex); 1324 if (atomic_read(&p_dev->socket->present) != 0)
1316 if (!p_dev->socket->pcmcia_state.present) 1325 ret = p_dev;
1317 goto out;
1318
1319 if (p_dev->socket->pcmcia_state.dead)
1320 goto out;
1321 1326
1322 if (p_dev->_removed)
1323 goto out;
1324
1325 if (p_dev->suspended)
1326 goto out;
1327
1328 ret = p_dev;
1329 out:
1330 mutex_unlock(&p_dev->socket->ops_mutex);
1331 pcmcia_put_dev(p_dev); 1327 pcmcia_put_dev(p_dev);
1332 return ret; 1328 return ret;
1333} 1329}
@@ -1377,6 +1373,8 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1377 return ret; 1373 return ret;
1378 } 1374 }
1379 1375
1376 atomic_set(&socket->present, 0);
1377
1380 return 0; 1378 return 0;
1381} 1379}
1382 1380
@@ -1388,10 +1386,6 @@ static void pcmcia_bus_remove_socket(struct device *dev,
1388 if (!socket) 1386 if (!socket)
1389 return; 1387 return;
1390 1388
1391 mutex_lock(&socket->ops_mutex);
1392 socket->pcmcia_state.dead = 1;
1393 mutex_unlock(&socket->ops_mutex);
1394
1395 pccard_register_pcmcia(socket, NULL); 1389 pccard_register_pcmcia(socket, NULL);
1396 1390
1397 /* unregister any unbound devices */ 1391 /* unregister any unbound devices */
diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c
index 89cfddca089a..2e59fe947d28 100644
--- a/drivers/pcmcia/electra_cf.c
+++ b/drivers/pcmcia/electra_cf.c
@@ -31,6 +31,7 @@
31#include <linux/mm.h> 31#include <linux/mm.h>
32#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
33#include <linux/of_platform.h> 33#include <linux/of_platform.h>
34#include <linux/slab.h>
34 35
35#include <pcmcia/ss.h> 36#include <pcmcia/ss.h>
36 37
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index f5da62653313..3003bb3dfcc0 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -39,27 +39,11 @@ static struct pci_device_id i82092aa_pci_ids[] = {
39}; 39};
40MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids); 40MODULE_DEVICE_TABLE(pci, i82092aa_pci_ids);
41 41
42#ifdef CONFIG_PM
43static int i82092aa_socket_suspend (struct pci_dev *dev, pm_message_t state)
44{
45 return pcmcia_socket_dev_suspend(&dev->dev);
46}
47
48static int i82092aa_socket_resume (struct pci_dev *dev)
49{
50 return pcmcia_socket_dev_resume(&dev->dev);
51}
52#endif
53
54static struct pci_driver i82092aa_pci_driver = { 42static struct pci_driver i82092aa_pci_driver = {
55 .name = "i82092aa", 43 .name = "i82092aa",
56 .id_table = i82092aa_pci_ids, 44 .id_table = i82092aa_pci_ids,
57 .probe = i82092aa_pci_probe, 45 .probe = i82092aa_pci_probe,
58 .remove = __devexit_p(i82092aa_pci_remove), 46 .remove = __devexit_p(i82092aa_pci_remove),
59#ifdef CONFIG_PM
60 .suspend = i82092aa_socket_suspend,
61 .resume = i82092aa_socket_resume,
62#endif
63}; 47};
64 48
65 49
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index c13fd9360511..9e2a15628de5 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -40,7 +40,6 @@
40#include <linux/kernel.h> 40#include <linux/kernel.h>
41#include <linux/errno.h> 41#include <linux/errno.h>
42#include <linux/timer.h> 42#include <linux/timer.h>
43#include <linux/slab.h>
44#include <linux/ioport.h> 43#include <linux/ioport.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
46#include <linux/workqueue.h> 45#include <linux/workqueue.h>
@@ -1223,16 +1222,7 @@ static int pcic_init(struct pcmcia_socket *s)
1223 return 0; 1222 return 0;
1224} 1223}
1225 1224
1226static int i82365_drv_pcmcia_suspend(struct platform_device *dev,
1227 pm_message_t state)
1228{
1229 return pcmcia_socket_dev_suspend(&dev->dev);
1230}
1231 1225
1232static int i82365_drv_pcmcia_resume(struct platform_device *dev)
1233{
1234 return pcmcia_socket_dev_resume(&dev->dev);
1235}
1236static struct pccard_operations pcic_operations = { 1226static struct pccard_operations pcic_operations = {
1237 .init = pcic_init, 1227 .init = pcic_init,
1238 .get_status = pcic_get_status, 1228 .get_status = pcic_get_status,
@@ -1248,8 +1238,6 @@ static struct platform_driver i82365_driver = {
1248 .name = "i82365", 1238 .name = "i82365",
1249 .owner = THIS_MODULE, 1239 .owner = THIS_MODULE,
1250 }, 1240 },
1251 .suspend = i82365_drv_pcmcia_suspend,
1252 .resume = i82365_drv_pcmcia_resume,
1253}; 1241};
1254 1242
1255static struct platform_device *i82365_device; 1243static struct platform_device *i82365_device;
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 0ece2cd4a85e..7e16ed8eb0a4 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -16,7 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/timer.h> 18#include <linux/timer.h>
19#include <linux/slab.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/workqueue.h> 21#include <linux/workqueue.h>
@@ -685,16 +684,7 @@ static struct pccard_operations pcc_operations = {
685 .set_mem_map = pcc_set_mem_map, 684 .set_mem_map = pcc_set_mem_map,
686}; 685};
687 686
688static int cfc_drv_pcmcia_suspend(struct platform_device *dev,
689 pm_message_t state)
690{
691 return pcmcia_socket_dev_suspend(&dev->dev);
692}
693 687
694static int cfc_drv_pcmcia_resume(struct platform_device *dev)
695{
696 return pcmcia_socket_dev_resume(&dev->dev);
697}
698/*====================================================================*/ 688/*====================================================================*/
699 689
700static struct platform_driver pcc_driver = { 690static struct platform_driver pcc_driver = {
@@ -702,8 +692,6 @@ static struct platform_driver pcc_driver = {
702 .name = "cfc", 692 .name = "cfc",
703 .owner = THIS_MODULE, 693 .owner = THIS_MODULE,
704 }, 694 },
705 .suspend = cfc_drv_pcmcia_suspend,
706 .resume = cfc_drv_pcmcia_resume,
707}; 695};
708 696
709static struct platform_device pcc_device = { 697static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 72844c5a6d05..6c5c3f910d71 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -16,7 +16,6 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/timer.h> 18#include <linux/timer.h>
19#include <linux/slab.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/delay.h> 20#include <linux/delay.h>
22#include <linux/workqueue.h> 21#include <linux/workqueue.h>
@@ -663,16 +662,6 @@ static struct pccard_operations pcc_operations = {
663 .set_mem_map = pcc_set_mem_map, 662 .set_mem_map = pcc_set_mem_map,
664}; 663};
665 664
666static int pcc_drv_pcmcia_suspend(struct platform_device *dev,
667 pm_message_t state)
668{
669 return pcmcia_socket_dev_suspend(&dev->dev);
670}
671
672static int pcc_drv_pcmcia_resume(struct platform_device *dev)
673{
674 return pcmcia_socket_dev_resume(&dev->dev);
675}
676/*====================================================================*/ 665/*====================================================================*/
677 666
678static struct platform_driver pcc_driver = { 667static struct platform_driver pcc_driver = {
@@ -680,8 +669,6 @@ static struct platform_driver pcc_driver = {
680 .name = "pcc", 669 .name = "pcc",
681 .owner = THIS_MODULE, 670 .owner = THIS_MODULE,
682 }, 671 },
683 .suspend = pcc_drv_pcmcia_suspend,
684 .resume = pcc_drv_pcmcia_resume,
685}; 672};
686 673
687static struct platform_device pcc_device = { 674static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index 61c215918128..41cc954a5ffe 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -42,7 +42,6 @@
42 42
43#include <linux/kernel.h> 43#include <linux/kernel.h>
44#include <linux/errno.h> 44#include <linux/errno.h>
45#include <linux/slab.h>
46#include <linux/timer.h> 45#include <linux/timer.h>
47#include <linux/ioport.h> 46#include <linux/ioport.h>
48#include <linux/delay.h> 47#include <linux/delay.h>
@@ -1288,21 +1287,6 @@ static int m8xx_remove(struct of_device *ofdev)
1288 return 0; 1287 return 0;
1289} 1288}
1290 1289
1291#ifdef CONFIG_PM
1292static int m8xx_suspend(struct platform_device *pdev, pm_message_t state)
1293{
1294 return pcmcia_socket_dev_suspend(&pdev->dev);
1295}
1296
1297static int m8xx_resume(struct platform_device *pdev)
1298{
1299 return pcmcia_socket_dev_resume(&pdev->dev);
1300}
1301#else
1302#define m8xx_suspend NULL
1303#define m8xx_resume NULL
1304#endif
1305
1306static const struct of_device_id m8xx_pcmcia_match[] = { 1290static const struct of_device_id m8xx_pcmcia_match[] = {
1307 { 1291 {
1308 .type = "pcmcia", 1292 .type = "pcmcia",
@@ -1318,8 +1302,6 @@ static struct of_platform_driver m8xx_pcmcia_driver = {
1318 .match_table = m8xx_pcmcia_match, 1302 .match_table = m8xx_pcmcia_match,
1319 .probe = m8xx_probe, 1303 .probe = m8xx_probe,
1320 .remove = m8xx_remove, 1304 .remove = m8xx_remove,
1321 .suspend = m8xx_suspend,
1322 .resume = m8xx_resume,
1323}; 1305};
1324 1306
1325static int __init m8xx_init(void) 1307static int __init m8xx_init(void)
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 3ef991552398..a7cfc7964c7c 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h>
19 20
20#include <pcmcia/ss.h> 21#include <pcmcia/ss.h>
21 22
@@ -330,24 +331,12 @@ static int __exit omap_cf_remove(struct platform_device *pdev)
330 return 0; 331 return 0;
331} 332}
332 333
333static int omap_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
334{
335 return pcmcia_socket_dev_suspend(&pdev->dev);
336}
337
338static int omap_cf_resume(struct platform_device *pdev)
339{
340 return pcmcia_socket_dev_resume(&pdev->dev);
341}
342
343static struct platform_driver omap_cf_driver = { 334static struct platform_driver omap_cf_driver = {
344 .driver = { 335 .driver = {
345 .name = (char *) driver_name, 336 .name = (char *) driver_name,
346 .owner = THIS_MODULE, 337 .owner = THIS_MODULE,
347 }, 338 },
348 .remove = __exit_p(omap_cf_remove), 339 .remove = __exit_p(omap_cf_remove),
349 .suspend = omap_cf_suspend,
350 .resume = omap_cf_resume,
351}; 340};
352 341
353static int __init omap_cf_init(void) 342static int __init omap_cf_init(void)
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 13a7132cf688..7631faa0cadd 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -27,6 +27,7 @@
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/slab.h>
30#include <linux/seq_file.h> 31#include <linux/seq_file.h>
31#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
32#include <linux/workqueue.h> 33#include <linux/workqueue.h>
@@ -710,7 +711,7 @@ static int ds_open(struct inode *inode, struct file *file)
710 warning_printed = 1; 711 warning_printed = 1;
711 } 712 }
712 713
713 if (s->pcmcia_state.present) 714 if (atomic_read(&s->present))
714 queue_event(user, CS_EVENT_CARD_INSERTION); 715 queue_event(user, CS_EVENT_CARD_INSERTION);
715out: 716out:
716 unlock_kernel(); 717 unlock_kernel();
@@ -769,9 +770,6 @@ static ssize_t ds_read(struct file *file, char __user *buf,
769 return -EIO; 770 return -EIO;
770 771
771 s = user->socket; 772 s = user->socket;
772 if (s->pcmcia_state.dead)
773 return -EIO;
774
775 ret = wait_event_interruptible(s->queue, !queue_empty(user)); 773 ret = wait_event_interruptible(s->queue, !queue_empty(user));
776 if (ret == 0) 774 if (ret == 0)
777 ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4; 775 ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4;
@@ -837,8 +835,6 @@ static int ds_ioctl(struct inode *inode, struct file *file,
837 return -EIO; 835 return -EIO;
838 836
839 s = user->socket; 837 s = user->socket;
840 if (s->pcmcia_state.dead)
841 return -EIO;
842 838
843 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; 839 size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
844 if (size > sizeof(ds_ioctl_arg_t)) 840 if (size > sizeof(ds_ioctl_arg_t))
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index c4612c52e4cb..7c3d03bb4f30 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -21,6 +21,7 @@
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/netdevice.h> 23#include <linux/netdevice.h>
24#include <linux/slab.h>
24 25
25#include <pcmcia/cs_types.h> 26#include <pcmcia/cs_types.h>
26#include <pcmcia/ss.h> 27#include <pcmcia/ss.h>
@@ -754,12 +755,12 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
754 else 755 else
755 printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n"); 756 printk(KERN_WARNING "pcmcia: Driver needs updating to support IRQ sharing.\n");
756 757
757#ifdef CONFIG_PCMCIA_PROBE 758 /* If the interrupt is already assigned, it must be the same */
758 759 if (s->irq.AssignedIRQ != 0)
759 if (s->irq.AssignedIRQ != 0) {
760 /* If the interrupt is already assigned, it must be the same */
761 irq = s->irq.AssignedIRQ; 760 irq = s->irq.AssignedIRQ;
762 } else { 761
762#ifdef CONFIG_PCMCIA_PROBE
763 if (!irq) {
763 int try; 764 int try;
764 u32 mask = s->irq_mask; 765 u32 mask = s->irq_mask;
765 void *data = p_dev; /* something unique to this device */ 766 void *data = p_dev; /* something unique to this device */
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 7ba57a565cd7..b61a13663a0a 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -9,18 +9,19 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include <linux/pci.h> 13#include <linux/pci.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/workqueue.h> 15#include <linux/workqueue.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/io.h>
17 19
18#include <pcmcia/cs_types.h> 20#include <pcmcia/cs_types.h>
19#include <pcmcia/ss.h> 21#include <pcmcia/ss.h>
20#include <pcmcia/cs.h> 22#include <pcmcia/cs.h>
21 23
22#include <asm/system.h> 24#include <asm/system.h>
23#include <asm/io.h>
24 25
25#include "pd6729.h" 26#include "pd6729.h"
26#include "i82365.h" 27#include "i82365.h"
@@ -222,9 +223,9 @@ static irqreturn_t pd6729_interrupt(int irq, void *dev)
222 ? SS_READY : 0; 223 ? SS_READY : 0;
223 } 224 }
224 225
225 if (events) { 226 if (events)
226 pcmcia_parse_events(&socket[i].socket, events); 227 pcmcia_parse_events(&socket[i].socket, events);
227 } 228
228 active |= events; 229 active |= events;
229 } 230 }
230 231
@@ -256,9 +257,8 @@ static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value)
256 status = indirect_read(socket, I365_STATUS); 257 status = indirect_read(socket, I365_STATUS);
257 *value = 0; 258 *value = 0;
258 259
259 if ((status & I365_CS_DETECT) == I365_CS_DETECT) { 260 if ((status & I365_CS_DETECT) == I365_CS_DETECT)
260 *value |= SS_DETECT; 261 *value |= SS_DETECT;
261 }
262 262
263 /* 263 /*
264 * IO cards have a different meaning of bits 0,1 264 * IO cards have a different meaning of bits 0,1
@@ -308,7 +308,7 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
308 socket->card_irq = state->io_irq; 308 socket->card_irq = state->io_irq;
309 309
310 reg = 0; 310 reg = 0;
311 /* The reset bit has "inverse" logic */ 311 /* The reset bit has "inverse" logic */
312 if (!(state->flags & SS_RESET)) 312 if (!(state->flags & SS_RESET))
313 reg |= I365_PC_RESET; 313 reg |= I365_PC_RESET;
314 if (state->flags & SS_IOCARD) 314 if (state->flags & SS_IOCARD)
@@ -380,7 +380,7 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
380 indirect_write(socket, I365_POWER, reg); 380 indirect_write(socket, I365_POWER, reg);
381 381
382 if (irq_mode == 1) { 382 if (irq_mode == 1) {
383 /* all interrupts are to be done as PCI interrupts */ 383 /* all interrupts are to be done as PCI interrupts */
384 data = PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_CARD_IRQ; 384 data = PD67_EC1_INV_MGMT_IRQ | PD67_EC1_INV_CARD_IRQ;
385 } else 385 } else
386 data = 0; 386 data = 0;
@@ -391,9 +391,9 @@ static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
391 /* Enable specific interrupt events */ 391 /* Enable specific interrupt events */
392 392
393 reg = 0x00; 393 reg = 0x00;
394 if (state->csc_mask & SS_DETECT) { 394 if (state->csc_mask & SS_DETECT)
395 reg |= I365_CSC_DETECT; 395 reg |= I365_CSC_DETECT;
396 } 396
397 if (state->flags & SS_IOCARD) { 397 if (state->flags & SS_IOCARD) {
398 if (state->csc_mask & SS_STSCHG) 398 if (state->csc_mask & SS_STSCHG)
399 reg |= I365_CSC_STSCHG; 399 reg |= I365_CSC_STSCHG;
@@ -450,9 +450,12 @@ static int pd6729_set_io_map(struct pcmcia_socket *sock,
450 450
451 ioctl = indirect_read(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map); 451 ioctl = indirect_read(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
452 452
453 if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map); 453 if (io->flags & MAP_0WS)
454 if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map); 454 ioctl |= I365_IOCTL_0WS(map);
455 if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map); 455 if (io->flags & MAP_16BIT)
456 ioctl |= I365_IOCTL_16BIT(map);
457 if (io->flags & MAP_AUTOSZ)
458 ioctl |= I365_IOCTL_IOCS16(map);
456 459
457 indirect_write(socket, I365_IOCTL, ioctl); 460 indirect_write(socket, I365_IOCTL, ioctl);
458 461
@@ -497,7 +500,7 @@ static int pd6729_set_mem_map(struct pcmcia_socket *sock,
497 500
498 /* write the stop address */ 501 /* write the stop address */
499 502
500 i= (mem->res->end >> 12) & 0x0fff; 503 i = (mem->res->end >> 12) & 0x0fff;
501 switch (to_cycles(mem->speed)) { 504 switch (to_cycles(mem->speed)) {
502 case 0: 505 case 0:
503 break; 506 break;
@@ -563,7 +566,7 @@ static int pd6729_init(struct pcmcia_socket *sock)
563 566
564/* the pccard structure and its functions */ 567/* the pccard structure and its functions */
565static struct pccard_operations pd6729_operations = { 568static struct pccard_operations pd6729_operations = {
566 .init = pd6729_init, 569 .init = pd6729_init,
567 .get_status = pd6729_get_status, 570 .get_status = pd6729_get_status,
568 .set_socket = pd6729_set_socket, 571 .set_socket = pd6729_set_socket,
569 .set_io_map = pd6729_set_io_map, 572 .set_io_map = pd6729_set_io_map,
@@ -578,8 +581,13 @@ static irqreturn_t pd6729_test(int irq, void *dev)
578 581
579static int pd6729_check_irq(int irq) 582static int pd6729_check_irq(int irq)
580{ 583{
581 if (request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x", pd6729_test) 584 int ret;
582 != 0) return -1; 585
586 ret = request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x",
587 pd6729_test);
588 if (ret)
589 return -1;
590
583 free_irq(irq, pd6729_test); 591 free_irq(irq, pd6729_test);
584 return 0; 592 return 0;
585} 593}
@@ -591,7 +599,7 @@ static u_int __devinit pd6729_isa_scan(void)
591 599
592 if (irq_mode == 1) { 600 if (irq_mode == 1) {
593 printk(KERN_INFO "pd6729: PCI card interrupts, " 601 printk(KERN_INFO "pd6729: PCI card interrupts, "
594 "PCI status changes\n"); 602 "PCI status changes\n");
595 return 0; 603 return 0;
596 } 604 }
597 605
@@ -607,9 +615,10 @@ static u_int __devinit pd6729_isa_scan(void)
607 if (mask & (1<<i)) 615 if (mask & (1<<i))
608 printk("%s%d", ((mask & ((1<<i)-1)) ? "," : ""), i); 616 printk("%s%d", ((mask & ((1<<i)-1)) ? "," : ""), i);
609 617
610 if (mask == 0) printk("none!"); 618 if (mask == 0)
611 619 printk("none!");
612 printk(" polling status changes.\n"); 620 else
621 printk(" polling status changes.\n");
613 622
614 return mask; 623 return mask;
615} 624}
@@ -624,11 +633,16 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
624 633
625 socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, 634 socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
626 GFP_KERNEL); 635 GFP_KERNEL);
627 if (!socket) 636 if (!socket) {
637 dev_warn(&dev->dev, "failed to kzalloc socket.\n");
628 return -ENOMEM; 638 return -ENOMEM;
639 }
629 640
630 if ((ret = pci_enable_device(dev))) 641 ret = pci_enable_device(dev);
642 if (ret) {
643 dev_warn(&dev->dev, "failed to enable pci_device.\n");
631 goto err_out_free_mem; 644 goto err_out_free_mem;
645 }
632 646
633 if (!pci_resource_start(dev, 0)) { 647 if (!pci_resource_start(dev, 0)) {
634 dev_warn(&dev->dev, "refusing to load the driver as the " 648 dev_warn(&dev->dev, "refusing to load the driver as the "
@@ -639,7 +653,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
639 dev_info(&dev->dev, "Cirrus PD6729 PCI to PCMCIA Bridge at 0x%llx " 653 dev_info(&dev->dev, "Cirrus PD6729 PCI to PCMCIA Bridge at 0x%llx "
640 "on irq %d\n", 654 "on irq %d\n",
641 (unsigned long long)pci_resource_start(dev, 0), dev->irq); 655 (unsigned long long)pci_resource_start(dev, 0), dev->irq);
642 /* 656 /*
643 * Since we have no memory BARs some firmware may not 657 * Since we have no memory BARs some firmware may not
644 * have had PCI_COMMAND_MEMORY enabled, yet the device needs it. 658 * have had PCI_COMMAND_MEMORY enabled, yet the device needs it.
645 */ 659 */
@@ -685,8 +699,9 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
685 pci_set_drvdata(dev, socket); 699 pci_set_drvdata(dev, socket);
686 if (irq_mode == 1) { 700 if (irq_mode == 1) {
687 /* Register the interrupt handler */ 701 /* Register the interrupt handler */
688 if ((ret = request_irq(dev->irq, pd6729_interrupt, IRQF_SHARED, 702 ret = request_irq(dev->irq, pd6729_interrupt, IRQF_SHARED,
689 "pd6729", socket))) { 703 "pd6729", socket);
704 if (ret) {
690 dev_err(&dev->dev, "Failed to register irq %d\n", 705 dev_err(&dev->dev, "Failed to register irq %d\n",
691 dev->irq); 706 dev->irq);
692 goto err_out_free_res; 707 goto err_out_free_res;
@@ -750,18 +765,6 @@ static void __devexit pd6729_pci_remove(struct pci_dev *dev)
750 kfree(socket); 765 kfree(socket);
751} 766}
752 767
753#ifdef CONFIG_PM
754static int pd6729_socket_suspend(struct pci_dev *dev, pm_message_t state)
755{
756 return pcmcia_socket_dev_suspend(&dev->dev);
757}
758
759static int pd6729_socket_resume(struct pci_dev *dev)
760{
761 return pcmcia_socket_dev_resume(&dev->dev);
762}
763#endif
764
765static struct pci_device_id pd6729_pci_ids[] = { 768static struct pci_device_id pd6729_pci_ids[] = {
766 { 769 {
767 .vendor = PCI_VENDOR_ID_CIRRUS, 770 .vendor = PCI_VENDOR_ID_CIRRUS,
@@ -778,10 +781,6 @@ static struct pci_driver pd6729_pci_driver = {
778 .id_table = pd6729_pci_ids, 781 .id_table = pd6729_pci_ids,
779 .probe = pd6729_pci_probe, 782 .probe = pd6729_pci_probe,
780 .remove = __devexit_p(pd6729_pci_remove), 783 .remove = __devexit_p(pd6729_pci_remove),
781#ifdef CONFIG_PM
782 .suspend = pd6729_socket_suspend,
783 .resume = pd6729_socket_resume,
784#endif
785}; 784};
786 785
787static int pd6729_module_init(void) 786static int pd6729_module_init(void)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 76e640bccde8..df4532e91b1a 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -17,6 +17,7 @@
17 ======================================================================*/ 17 ======================================================================*/
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/slab.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/cpufreq.h> 22#include <linux/cpufreq.h>
22#include <linux/ioport.h> 23#include <linux/ioport.h>
@@ -325,19 +326,13 @@ static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
325 return 0; 326 return 0;
326} 327}
327 328
328static int pxa2xx_drv_pcmcia_suspend(struct device *dev)
329{
330 return pcmcia_socket_dev_suspend(dev);
331}
332
333static int pxa2xx_drv_pcmcia_resume(struct device *dev) 329static int pxa2xx_drv_pcmcia_resume(struct device *dev)
334{ 330{
335 pxa2xx_configure_sockets(dev); 331 pxa2xx_configure_sockets(dev);
336 return pcmcia_socket_dev_resume(dev); 332 return 0;
337} 333}
338 334
339static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = { 335static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = {
340 .suspend = pxa2xx_drv_pcmcia_suspend,
341 .resume = pxa2xx_drv_pcmcia_resume, 336 .resume = pxa2xx_drv_pcmcia_resume,
342}; 337};
343 338
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index 452c83b512c4..ffa5f3cae57b 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -12,6 +12,7 @@
12 * (C) 1999 David A. Hinds 12 * (C) 1999 David A. Hinds
13 */ 13 */
14 14
15#include <linux/slab.h>
15#include <linux/module.h> 16#include <linux/module.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17 18
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 4663b3fa9f96..a6eb7b59ba9f 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -214,7 +214,7 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
214 return; 214 return;
215 } 215 }
216 for (i = base, most = 0; i < base+num; i += 8) { 216 for (i = base, most = 0; i < base+num; i += 8) {
217 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe"); 217 res = claim_region(s, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
218 if (!res) 218 if (!res)
219 continue; 219 continue;
220 hole = inb(i); 220 hole = inb(i);
@@ -231,9 +231,14 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
231 231
232 bad = any = 0; 232 bad = any = 0;
233 for (i = base; i < base+num; i += 8) { 233 for (i = base; i < base+num; i += 8) {
234 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA ioprobe"); 234 res = claim_region(s, i, 8, IORESOURCE_IO, "PCMCIA ioprobe");
235 if (!res) 235 if (!res) {
236 if (!any)
237 printk(" excluding");
238 if (!bad)
239 bad = any = i;
236 continue; 240 continue;
241 }
237 for (j = 0; j < 8; j++) 242 for (j = 0; j < 8; j++)
238 if (inb(i+j) != most) 243 if (inb(i+j) != most)
239 break; 244 break;
@@ -253,6 +258,7 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
253 } 258 }
254 if (bad) { 259 if (bad) {
255 if ((num > 16) && (bad == base) && (i == base+num)) { 260 if ((num > 16) && (bad == base) && (i == base+num)) {
261 sub_interval(&s_data->io_db, bad, i-bad);
256 printk(" nothing: probe failed.\n"); 262 printk(" nothing: probe failed.\n");
257 return; 263 return;
258 } else { 264 } else {
@@ -596,19 +602,17 @@ struct pcmcia_align_data {
596 struct resource_map *map; 602 struct resource_map *map;
597}; 603};
598 604
599static resource_size_t 605static resource_size_t pcmcia_common_align(struct pcmcia_align_data *align_data,
600pcmcia_common_align(void *align_data, const struct resource *res, 606 resource_size_t start)
601 resource_size_t size, resource_size_t align)
602{ 607{
603 struct pcmcia_align_data *data = align_data; 608 resource_size_t ret;
604 resource_size_t start;
605 /* 609 /*
606 * Ensure that we have the correct start address 610 * Ensure that we have the correct start address
607 */ 611 */
608 start = (res->start & ~data->mask) + data->offset; 612 ret = (start & ~align_data->mask) + align_data->offset;
609 if (start < res->start) 613 if (ret < start)
610 start += data->mask + 1; 614 ret += align_data->mask + 1;
611 return start; 615 return ret;
612} 616}
613 617
614static resource_size_t 618static resource_size_t
@@ -619,29 +623,28 @@ pcmcia_align(void *align_data, const struct resource *res,
619 struct resource_map *m; 623 struct resource_map *m;
620 resource_size_t start; 624 resource_size_t start;
621 625
622 start = pcmcia_common_align(data, res, size, align); 626 start = pcmcia_common_align(data, res->start);
623 627
624 for (m = data->map->next; m != data->map; m = m->next) { 628 for (m = data->map->next; m != data->map; m = m->next) {
625 unsigned long start = m->base; 629 unsigned long map_start = m->base;
626 unsigned long end = m->base + m->num - 1; 630 unsigned long map_end = m->base + m->num - 1;
627 631
628 /* 632 /*
629 * If the lower resources are not available, try aligning 633 * If the lower resources are not available, try aligning
630 * to this entry of the resource database to see if it'll 634 * to this entry of the resource database to see if it'll
631 * fit here. 635 * fit here.
632 */ 636 */
633 if (res->start < start) { 637 if (start < map_start)
634 start = pcmcia_common_align(data, res, size, align); 638 start = pcmcia_common_align(data, map_start);
635 }
636 639
637 /* 640 /*
638 * If we're above the area which was passed in, there's 641 * If we're above the area which was passed in, there's
639 * no point proceeding. 642 * no point proceeding.
640 */ 643 */
641 if (res->start >= res->end) 644 if (start >= res->end)
642 break; 645 break;
643 646
644 if ((res->start + size - 1) <= end) 647 if ((start + size - 1) <= map_end)
645 break; 648 break;
646 } 649 }
647 650
@@ -807,9 +810,18 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
807static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end) 810static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end)
808{ 811{
809 struct socket_data *data = s->resource_data; 812 struct socket_data *data = s->resource_data;
810 unsigned long size = end - start + 1; 813 unsigned long size;
811 int ret = 0; 814 int ret = 0;
812 815
816#if defined(CONFIG_X86)
817 /* on x86, avoid anything < 0x100 for it is often used for
818 * legacy platform devices */
819 if (start < 0x100)
820 start = 0x100;
821#endif
822
823 size = end - start + 1;
824
813 if (end < start) 825 if (end < start)
814 return -EINVAL; 826 return -EINVAL;
815 827
@@ -867,10 +879,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
867 if (res == &ioport_resource) 879 if (res == &ioport_resource)
868 continue; 880 continue;
869 dev_printk(KERN_INFO, &s->cb_dev->dev, 881 dev_printk(KERN_INFO, &s->cb_dev->dev,
870 "pcmcia: parent PCI bridge I/O " 882 "pcmcia: parent PCI bridge window: %pR\n",
871 "window: 0x%llx - 0x%llx\n", 883 res);
872 (unsigned long long)res->start,
873 (unsigned long long)res->end);
874 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 884 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
875 done |= IORESOURCE_IO; 885 done |= IORESOURCE_IO;
876 886
@@ -880,10 +890,8 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
880 if (res == &iomem_resource) 890 if (res == &iomem_resource)
881 continue; 891 continue;
882 dev_printk(KERN_INFO, &s->cb_dev->dev, 892 dev_printk(KERN_INFO, &s->cb_dev->dev,
883 "pcmcia: parent PCI bridge Memory " 893 "pcmcia: parent PCI bridge window: %pR\n",
884 "window: 0x%llx - 0x%llx\n", 894 res);
885 (unsigned long long)res->start,
886 (unsigned long long)res->end);
887 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 895 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
888 done |= IORESOURCE_MEM; 896 done |= IORESOURCE_MEM;
889 } 897 }
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index 8db86b90c200..edbd8c472628 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -32,6 +32,7 @@
32 32
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/slab.h>
35#include <linux/platform_device.h> 36#include <linux/platform_device.h>
36 37
37#include <pcmcia/cs_types.h> 38#include <pcmcia/cs_types.h>
@@ -95,17 +96,6 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev)
95 return 0; 96 return 0;
96} 97}
97 98
98static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev,
99 pm_message_t state)
100{
101 return pcmcia_socket_dev_suspend(&dev->dev);
102}
103
104static int sa11x0_drv_pcmcia_resume(struct platform_device *dev)
105{
106 return pcmcia_socket_dev_resume(&dev->dev);
107}
108
109static struct platform_driver sa11x0_pcmcia_driver = { 99static struct platform_driver sa11x0_pcmcia_driver = {
110 .driver = { 100 .driver = {
111 .name = "sa11x0-pcmcia", 101 .name = "sa11x0-pcmcia",
@@ -113,8 +103,6 @@ static struct platform_driver sa11x0_pcmcia_driver = {
113 }, 103 },
114 .probe = sa11x0_drv_pcmcia_probe, 104 .probe = sa11x0_drv_pcmcia_probe,
115 .remove = sa11x0_drv_pcmcia_remove, 105 .remove = sa11x0_drv_pcmcia_remove,
116 .suspend = sa11x0_drv_pcmcia_suspend,
117 .resume = sa11x0_drv_pcmcia_resume,
118}; 106};
119 107
120/* sa11x0_pcmcia_init() 108/* sa11x0_pcmcia_init()
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
index db79ca61cf96..59866905ea37 100644
--- a/drivers/pcmcia/sa1111_generic.c
+++ b/drivers/pcmcia/sa1111_generic.c
@@ -12,6 +12,7 @@
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/slab.h>
15 16
16#include <pcmcia/ss.h> 17#include <pcmcia/ss.h>
17 18
@@ -213,16 +214,6 @@ static int __devexit pcmcia_remove(struct sa1111_dev *dev)
213 return 0; 214 return 0;
214} 215}
215 216
216static int pcmcia_suspend(struct sa1111_dev *dev, pm_message_t state)
217{
218 return pcmcia_socket_dev_suspend(&dev->dev);
219}
220
221static int pcmcia_resume(struct sa1111_dev *dev)
222{
223 return pcmcia_socket_dev_resume(&dev->dev);
224}
225
226static struct sa1111_driver pcmcia_driver = { 217static struct sa1111_driver pcmcia_driver = {
227 .drv = { 218 .drv = {
228 .name = "sa1111-pcmcia", 219 .name = "sa1111-pcmcia",
@@ -230,8 +221,6 @@ static struct sa1111_driver pcmcia_driver = {
230 .devid = SA1111_DEVID_PCMCIA, 221 .devid = SA1111_DEVID_PCMCIA,
231 .probe = pcmcia_probe, 222 .probe = pcmcia_probe,
232 .remove = __devexit_p(pcmcia_remove), 223 .remove = __devexit_p(pcmcia_remove),
233 .suspend = pcmcia_suspend,
234 .resume = pcmcia_resume,
235}; 224};
236 225
237static int __init sa1111_drv_pcmcia_init(void) 226static int __init sa1111_drv_pcmcia_init(void)
diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
index fc9a6527019b..fa28d8911b00 100644
--- a/drivers/pcmcia/sa11xx_base.c
+++ b/drivers/pcmcia/sa11xx_base.c
@@ -37,6 +37,7 @@
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/slab.h>
40 41
41#include <mach/hardware.h> 42#include <mach/hardware.h>
42#include <asm/irq.h> 43#include <asm/irq.h>
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 08278016e58d..80e36bc407da 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -15,7 +15,6 @@
15#include <linux/string.h> 15#include <linux/string.h>
16#include <linux/major.h> 16#include <linux/major.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/slab.h>
19#include <linux/mm.h> 18#include <linux/mm.h>
20#include <linux/interrupt.h> 19#include <linux/interrupt.h>
21#include <linux/timer.h> 20#include <linux/timer.h>
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 12c49ee135e1..56004a1b5bba 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -39,7 +39,6 @@
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/errno.h> 40#include <linux/errno.h>
41#include <linux/interrupt.h> 41#include <linux/interrupt.h>
42#include <linux/slab.h>
43#include <linux/timer.h> 42#include <linux/timer.h>
44#include <linux/ioport.h> 43#include <linux/ioport.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
@@ -348,16 +347,6 @@ static int __init get_tcic_id(void)
348 return id; 347 return id;
349} 348}
350 349
351static int tcic_drv_pcmcia_suspend(struct platform_device *dev,
352 pm_message_t state)
353{
354 return pcmcia_socket_dev_suspend(&dev->dev);
355}
356
357static int tcic_drv_pcmcia_resume(struct platform_device *dev)
358{
359 return pcmcia_socket_dev_resume(&dev->dev);
360}
361/*====================================================================*/ 350/*====================================================================*/
362 351
363static struct platform_driver tcic_driver = { 352static struct platform_driver tcic_driver = {
@@ -365,8 +354,6 @@ static struct platform_driver tcic_driver = {
365 .name = "tcic-pcmcia", 354 .name = "tcic-pcmcia",
366 .owner = THIS_MODULE, 355 .owner = THIS_MODULE,
367 }, 356 },
368 .suspend = tcic_drv_pcmcia_suspend,
369 .resume = tcic_drv_pcmcia_resume,
370}; 357};
371 358
372static struct platform_device tcic_device = { 359static struct platform_device tcic_device = {
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index aaccdb9f4ba1..86e4a1a3c642 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -705,24 +705,11 @@ static int __devinit vrc4171_card_setup(char *options)
705 705
706__setup("vrc4171_card=", vrc4171_card_setup); 706__setup("vrc4171_card=", vrc4171_card_setup);
707 707
708static int vrc4171_card_suspend(struct platform_device *dev,
709 pm_message_t state)
710{
711 return pcmcia_socket_dev_suspend(&dev->dev);
712}
713
714static int vrc4171_card_resume(struct platform_device *dev)
715{
716 return pcmcia_socket_dev_resume(&dev->dev);
717}
718
719static struct platform_driver vrc4171_card_driver = { 708static struct platform_driver vrc4171_card_driver = {
720 .driver = { 709 .driver = {
721 .name = vrc4171_card_name, 710 .name = vrc4171_card_name,
722 .owner = THIS_MODULE, 711 .owner = THIS_MODULE,
723 }, 712 },
724 .suspend = vrc4171_card_suspend,
725 .resume = vrc4171_card_resume,
726}; 713};
727 714
728static int __devinit vrc4171_card_init(void) 715static int __devinit vrc4171_card_init(void)
diff --git a/drivers/pcmcia/xxs1500_ss.c b/drivers/pcmcia/xxs1500_ss.c
index f9009d34254b..201ccfa1e97b 100644
--- a/drivers/pcmcia/xxs1500_ss.c
+++ b/drivers/pcmcia/xxs1500_ss.c
@@ -14,6 +14,7 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/pm.h> 15#include <linux/pm.h>
16#include <linux/resource.h> 16#include <linux/resource.h>
17#include <linux/slab.h>
17#include <linux/spinlock.h> 18#include <linux/spinlock.h>
18 19
19#include <pcmcia/cs_types.h> 20#include <pcmcia/cs_types.h>
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 418988ab6edf..83ace277426c 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -17,6 +17,7 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/slab.h>
20 21
21#include <pcmcia/cs_types.h> 22#include <pcmcia/cs_types.h>
22#include <pcmcia/ss.h> 23#include <pcmcia/ss.h>
@@ -1290,12 +1291,9 @@ static int yenta_dev_suspend_noirq(struct device *dev)
1290{ 1291{
1291 struct pci_dev *pdev = to_pci_dev(dev); 1292 struct pci_dev *pdev = to_pci_dev(dev);
1292 struct yenta_socket *socket = pci_get_drvdata(pdev); 1293 struct yenta_socket *socket = pci_get_drvdata(pdev);
1293 int ret;
1294
1295 ret = pcmcia_socket_dev_suspend(dev);
1296 1294
1297 if (!socket) 1295 if (!socket)
1298 return ret; 1296 return 0;
1299 1297
1300 if (socket->type && socket->type->save_state) 1298 if (socket->type && socket->type->save_state)
1301 socket->type->save_state(socket); 1299 socket->type->save_state(socket);
@@ -1312,7 +1310,7 @@ static int yenta_dev_suspend_noirq(struct device *dev)
1312 */ 1310 */
1313 /* pci_set_power_state(dev, 3); */ 1311 /* pci_set_power_state(dev, 3); */
1314 1312
1315 return ret; 1313 return 0;
1316} 1314}
1317 1315
1318static int yenta_dev_resume_noirq(struct device *dev) 1316static int yenta_dev_resume_noirq(struct device *dev)
@@ -1336,26 +1334,16 @@ static int yenta_dev_resume_noirq(struct device *dev)
1336 if (socket->type && socket->type->restore_state) 1334 if (socket->type && socket->type->restore_state)
1337 socket->type->restore_state(socket); 1335 socket->type->restore_state(socket);
1338 1336
1339 pcmcia_socket_dev_early_resume(dev);
1340 return 0;
1341}
1342
1343static int yenta_dev_resume(struct device *dev)
1344{
1345 pcmcia_socket_dev_late_resume(dev);
1346 return 0; 1337 return 0;
1347} 1338}
1348 1339
1349static const struct dev_pm_ops yenta_pm_ops = { 1340static const struct dev_pm_ops yenta_pm_ops = {
1350 .suspend_noirq = yenta_dev_suspend_noirq, 1341 .suspend_noirq = yenta_dev_suspend_noirq,
1351 .resume_noirq = yenta_dev_resume_noirq, 1342 .resume_noirq = yenta_dev_resume_noirq,
1352 .resume = yenta_dev_resume,
1353 .freeze_noirq = yenta_dev_suspend_noirq, 1343 .freeze_noirq = yenta_dev_suspend_noirq,
1354 .thaw_noirq = yenta_dev_resume_noirq, 1344 .thaw_noirq = yenta_dev_resume_noirq,
1355 .thaw = yenta_dev_resume,
1356 .poweroff_noirq = yenta_dev_suspend_noirq, 1345 .poweroff_noirq = yenta_dev_suspend_noirq,
1357 .restore_noirq = yenta_dev_resume_noirq, 1346 .restore_noirq = yenta_dev_resume_noirq,
1358 .restore = yenta_dev_resume,
1359}; 1347};
1360 1348
1361#define YENTA_PM_OPS (&yenta_pm_ops) 1349#define YENTA_PM_OPS (&yenta_pm_ops)