1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <linux/string.h>
20#include <linux/major.h>
21#include <linux/errno.h>
22#include <linux/slab.h>
23#include <linux/mm.h>
24#include <linux/interrupt.h>
25#include <linux/timer.h>
26#include <linux/ioport.h>
27#include <linux/delay.h>
28#include <linux/pm.h>
29#include <linux/device.h>
30#include <linux/kthread.h>
31#include <linux/freezer.h>
32#include <asm/irq.h>
33
34#include <pcmcia/ss.h>
35#include <pcmcia/cistpl.h>
36#include <pcmcia/cisreg.h>
37#include <pcmcia/ds.h>
38#include "cs_internal.h"
39
40
41
42
43MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
44MODULE_DESCRIPTION("Linux Kernel Card Services");
45MODULE_LICENSE("GPL");
46
47#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
48
49INT_MODULE_PARM(setup_delay, 10);
50INT_MODULE_PARM(resume_delay, 20);
51INT_MODULE_PARM(shutdown_delay, 3);
52INT_MODULE_PARM(vcc_settle, 40);
53INT_MODULE_PARM(reset_time, 10);
54INT_MODULE_PARM(unreset_delay, 10);
55INT_MODULE_PARM(unreset_check, 10);
56INT_MODULE_PARM(unreset_limit, 30);
57
58
59INT_MODULE_PARM(cis_speed, 300);
60
61
62socket_state_t dead_socket = {
63 .csc_mask = SS_DETECT,
64};
65EXPORT_SYMBOL(dead_socket);
66
67
68
69LIST_HEAD(pcmcia_socket_list);
70EXPORT_SYMBOL(pcmcia_socket_list);
71
72DECLARE_RWSEM(pcmcia_socket_list_rwsem);
73EXPORT_SYMBOL(pcmcia_socket_list_rwsem);
74
75
76struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt)
77{
78 struct device *dev = get_device(&skt->dev);
79 if (!dev)
80 return NULL;
81 return dev_get_drvdata(dev);
82}
83EXPORT_SYMBOL(pcmcia_get_socket);
84
85
86void pcmcia_put_socket(struct pcmcia_socket *skt)
87{
88 put_device(&skt->dev);
89}
90EXPORT_SYMBOL(pcmcia_put_socket);
91
92
93static void pcmcia_release_socket(struct device *dev)
94{
95 struct pcmcia_socket *socket = dev_get_drvdata(dev);
96
97 complete(&socket->socket_released);
98}
99
100static int pccardd(void *__skt);
101
102
103
104
105
106int pcmcia_register_socket(struct pcmcia_socket *socket)
107{
108 struct task_struct *tsk;
109 int ret;
110
111 if (!socket || !socket->ops || !socket->dev.parent || !socket->resource_ops)
112 return -EINVAL;
113
114 dev_dbg(&socket->dev, "pcmcia_register_socket(0x%p)\n", socket->ops);
115
116
117
118
119
120 down_write(&pcmcia_socket_list_rwsem);
121 if (list_empty(&pcmcia_socket_list))
122 socket->sock = 0;
123 else {
124 unsigned int found, i = 1;
125 struct pcmcia_socket *tmp;
126 do {
127 found = 1;
128 list_for_each_entry(tmp, &pcmcia_socket_list, socket_list) {
129 if (tmp->sock == i)
130 found = 0;
131 }
132 i++;
133 } while (!found);
134 socket->sock = i - 1;
135 }
136 list_add_tail(&socket->socket_list, &pcmcia_socket_list);
137 up_write(&pcmcia_socket_list_rwsem);
138
139#ifndef CONFIG_CARDBUS
140
141
142
143
144 socket->features &= ~SS_CAP_CARDBUS;
145#endif
146
147
148 dev_set_drvdata(&socket->dev, socket);
149 socket->dev.class = &pcmcia_socket_class;
150 dev_set_name(&socket->dev, "pcmcia_socket%u", socket->sock);
151
152
153 socket->cis_mem.flags = 0;
154 socket->cis_mem.speed = cis_speed;
155
156 INIT_LIST_HEAD(&socket->cis_cache);
157
158 init_completion(&socket->socket_released);
159 init_completion(&socket->thread_done);
160 mutex_init(&socket->skt_mutex);
161 mutex_init(&socket->ops_mutex);
162 spin_lock_init(&socket->thread_lock);
163
164 if (socket->resource_ops->init) {
165 mutex_lock(&socket->ops_mutex);
166 ret = socket->resource_ops->init(socket);
167 mutex_unlock(&socket->ops_mutex);
168 if (ret)
169 goto err;
170 }
171
172 tsk = kthread_run(pccardd, socket, "pccardd");
173 if (IS_ERR(tsk)) {
174 ret = PTR_ERR(tsk);
175 goto err;
176 }
177
178 wait_for_completion(&socket->thread_done);
179 if (!socket->thread) {
180 dev_printk(KERN_WARNING, &socket->dev,
181 "PCMCIA: warning: socket thread did not start\n");
182 return -EIO;
183 }
184
185 pcmcia_parse_events(socket, SS_DETECT);
186
187
188
189
190
191
192 request_module_nowait("pcmcia");
193
194 return 0;
195
196 err:
197 down_write(&pcmcia_socket_list_rwsem);
198 list_del(&socket->socket_list);
199 up_write(&pcmcia_socket_list_rwsem);
200 return ret;
201}
202EXPORT_SYMBOL(pcmcia_register_socket);
203
204
205
206
207
208
209void pcmcia_unregister_socket(struct pcmcia_socket *socket)
210{
211 if (!socket)
212 return;
213
214 dev_dbg(&socket->dev, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
215
216 if (socket->thread)
217 kthread_stop(socket->thread);
218
219
220 down_write(&pcmcia_socket_list_rwsem);
221 list_del(&socket->socket_list);
222 up_write(&pcmcia_socket_list_rwsem);
223
224
225 if (socket->resource_ops->exit) {
226 mutex_lock(&socket->ops_mutex);
227 socket->resource_ops->exit(socket);
228 mutex_unlock(&socket->ops_mutex);
229 }
230 wait_for_completion(&socket->socket_released);
231}
232EXPORT_SYMBOL(pcmcia_unregister_socket);
233
234
235struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr)
236{
237 struct pcmcia_socket *s;
238
239 down_read(&pcmcia_socket_list_rwsem);
240 list_for_each_entry(s, &pcmcia_socket_list, socket_list)
241 if (s->sock == nr) {
242 up_read(&pcmcia_socket_list_rwsem);
243 return s;
244 }
245 up_read(&pcmcia_socket_list_rwsem);
246
247 return NULL;
248
249}
250EXPORT_SYMBOL(pcmcia_get_socket_by_nr);
251
252static int socket_reset(struct pcmcia_socket *skt)
253{
254 int status, i;
255
256 dev_dbg(&skt->dev, "reset\n");
257
258 skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET;
259 skt->ops->set_socket(skt, &skt->socket);
260 udelay((long)reset_time);
261
262 skt->socket.flags &= ~SS_RESET;
263 skt->ops->set_socket(skt, &skt->socket);
264
265 msleep(unreset_delay * 10);
266 for (i = 0; i < unreset_limit; i++) {
267 skt->ops->get_status(skt, &status);
268
269 if (!(status & SS_DETECT))
270 return -ENODEV;
271
272 if (status & SS_READY)
273 return 0;
274
275 msleep(unreset_check * 10);
276 }
277
278 dev_printk(KERN_ERR, &skt->dev, "time out after reset.\n");
279 return -ETIMEDOUT;
280}
281
282
283
284
285
286
287
288static void socket_shutdown(struct pcmcia_socket *s)
289{
290 int status;
291
292 dev_dbg(&s->dev, "shutdown\n");
293
294 if (s->callback)
295 s->callback->remove(s);
296
297 mutex_lock(&s->ops_mutex);
298 s->state &= SOCKET_INUSE | SOCKET_PRESENT;
299 msleep(shutdown_delay * 10);
300 s->state &= SOCKET_INUSE;
301
302
303 s->socket = dead_socket;
304 s->ops->init(s);
305 s->ops->set_socket(s, &s->socket);
306 s->lock_count = 0;
307 kfree(s->fake_cis);
308 s->fake_cis = NULL;
309 s->functions = 0;
310
311
312
313
314
315
316
317 mutex_unlock(&s->ops_mutex);
318
319#ifdef CONFIG_CARDBUS
320 cb_free(s);
321#endif
322
323
324 msleep(100);
325
326 s->ops->get_status(s, &status);
327 if (status & SS_POWERON) {
328 dev_printk(KERN_ERR, &s->dev,
329 "*** DANGER *** unable to remove socket power\n");
330 }
331
332 s->state &= ~SOCKET_INUSE;
333}
334
335static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
336{
337 int status, i;
338
339 dev_dbg(&skt->dev, "setup\n");
340
341 skt->ops->get_status(skt, &status);
342 if (!(status & SS_DETECT))
343 return -ENODEV;
344
345 msleep(initial_delay * 10);
346
347 for (i = 0; i < 100; i++) {
348 skt->ops->get_status(skt, &status);
349 if (!(status & SS_DETECT))
350 return -ENODEV;
351
352 if (!(status & SS_PENDING))
353 break;
354
355 msleep(100);
356 }
357
358 if (status & SS_PENDING) {
359 dev_printk(KERN_ERR, &skt->dev,
360 "voltage interrogation timed out.\n");
361 return -ETIMEDOUT;
362 }
363
364 if (status & SS_CARDBUS) {
365 if (!(skt->features & SS_CAP_CARDBUS)) {
366 dev_printk(KERN_ERR, &skt->dev,
367 "cardbus cards are not supported.\n");
368 return -EINVAL;
369 }
370 skt->state |= SOCKET_CARDBUS;
371 } else
372 skt->state &= ~SOCKET_CARDBUS;
373
374
375
376
377 if (status & SS_3VCARD)
378 skt->socket.Vcc = skt->socket.Vpp = 33;
379 else if (!(status & SS_XVCARD))
380 skt->socket.Vcc = skt->socket.Vpp = 50;
381 else {
382 dev_printk(KERN_ERR, &skt->dev, "unsupported voltage key.\n");
383 return -EIO;
384 }
385
386 if (skt->power_hook)
387 skt->power_hook(skt, HOOK_POWER_PRE);
388
389 skt->socket.flags = 0;
390 skt->ops->set_socket(skt, &skt->socket);
391
392
393
394
395 msleep(vcc_settle * 10);
396
397 skt->ops->get_status(skt, &status);
398 if (!(status & SS_POWERON)) {
399 dev_printk(KERN_ERR, &skt->dev, "unable to apply power.\n");
400 return -EIO;
401 }
402
403 status = socket_reset(skt);
404
405 if (skt->power_hook)
406 skt->power_hook(skt, HOOK_POWER_POST);
407
408 return status;
409}
410
411
412
413
414
415static int socket_insert(struct pcmcia_socket *skt)
416{
417 int ret;
418
419 dev_dbg(&skt->dev, "insert\n");
420
421 mutex_lock(&skt->ops_mutex);
422 if (skt->state & SOCKET_INUSE) {
423 mutex_unlock(&skt->ops_mutex);
424 return -EINVAL;
425 }
426 skt->state |= SOCKET_INUSE;
427
428 ret = socket_setup(skt, setup_delay);
429 if (ret == 0) {
430 skt->state |= SOCKET_PRESENT;
431
432 dev_printk(KERN_NOTICE, &skt->dev,
433 "pccard: %s card inserted into slot %d\n",
434 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
435 skt->sock);
436
437#ifdef CONFIG_CARDBUS
438 if (skt->state & SOCKET_CARDBUS) {
439 cb_alloc(skt);
440 skt->state |= SOCKET_CARDBUS_CONFIG;
441 }
442#endif
443 dev_dbg(&skt->dev, "insert done\n");
444 mutex_unlock(&skt->ops_mutex);
445
446 if (!(skt->state & SOCKET_CARDBUS) && (skt->callback))
447 skt->callback->add(skt);
448 } else {
449 mutex_unlock(&skt->ops_mutex);
450 socket_shutdown(skt);
451 }
452
453 return ret;
454}
455
456static int socket_suspend(struct pcmcia_socket *skt)
457{
458 if (skt->state & SOCKET_SUSPEND)
459 return -EBUSY;
460
461 mutex_lock(&skt->ops_mutex);
462 skt->suspended_state = skt->state;
463
464 skt->socket = dead_socket;
465 skt->ops->set_socket(skt, &skt->socket);
466 if (skt->ops->suspend)
467 skt->ops->suspend(skt);
468 skt->state |= SOCKET_SUSPEND;
469 mutex_unlock(&skt->ops_mutex);
470 return 0;
471}
472
473static int socket_early_resume(struct pcmcia_socket *skt)
474{
475 mutex_lock(&skt->ops_mutex);
476 skt->socket = dead_socket;
477 skt->ops->init(skt);
478 skt->ops->set_socket(skt, &skt->socket);
479 if (skt->state & SOCKET_PRESENT)
480 skt->resume_status = socket_setup(skt, resume_delay);
481 mutex_unlock(&skt->ops_mutex);
482 return 0;
483}
484
485static int socket_late_resume(struct pcmcia_socket *skt)
486{
487 int ret = 0;
488
489 mutex_lock(&skt->ops_mutex);
490 skt->state &= ~SOCKET_SUSPEND;
491 mutex_unlock(&skt->ops_mutex);
492
493 if (!(skt->state & SOCKET_PRESENT)) {
494 ret = socket_insert(skt);
495 if (ret == -ENODEV)
496 ret = 0;
497 return ret;
498 }
499
500 if (skt->resume_status) {
501 socket_shutdown(skt);
502 return 0;
503 }
504
505 if (skt->suspended_state != skt->state) {
506 dev_dbg(&skt->dev,
507 "suspend state 0x%x != resume state 0x%x\n",
508 skt->suspended_state, skt->state);
509
510 socket_shutdown(skt);
511 return socket_insert(skt);
512 }
513
514 if (!(skt->state & SOCKET_CARDBUS) && (skt->callback))
515 ret = skt->callback->early_resume(skt);
516 return ret;
517}
518
519
520
521
522
523
524static int socket_complete_resume(struct pcmcia_socket *skt)
525{
526 int ret = 0;
527#ifdef CONFIG_CARDBUS
528 if (skt->state & SOCKET_CARDBUS) {
529
530
531
532 cb_free(skt);
533 ret = cb_alloc(skt);
534 if (ret)
535 cb_free(skt);
536 }
537#endif
538 return ret;
539}
540
541
542
543
544
545
546static int socket_resume(struct pcmcia_socket *skt)
547{
548 int err;
549 if (!(skt->state & SOCKET_SUSPEND))
550 return -EBUSY;
551
552 socket_early_resume(skt);
553 err = socket_late_resume(skt);
554 if (!err)
555 err = socket_complete_resume(skt);
556 return err;
557}
558
559static void socket_remove(struct pcmcia_socket *skt)
560{
561 dev_printk(KERN_NOTICE, &skt->dev,
562 "pccard: card ejected from slot %d\n", skt->sock);
563 socket_shutdown(skt);
564}
565
566
567
568
569
570
571
572
573
574
575
576
577static void socket_detect_change(struct pcmcia_socket *skt)
578{
579 if (!(skt->state & SOCKET_SUSPEND)) {
580 int status;
581
582 if (!(skt->state & SOCKET_PRESENT))
583 msleep(20);
584
585 skt->ops->get_status(skt, &status);
586 if ((skt->state & SOCKET_PRESENT) &&
587 !(status & SS_DETECT))
588 socket_remove(skt);
589 if (!(skt->state & SOCKET_PRESENT) &&
590 (status & SS_DETECT))
591 socket_insert(skt);
592 }
593}
594
595static int pccardd(void *__skt)
596{
597 struct pcmcia_socket *skt = __skt;
598 int ret;
599
600 skt->thread = current;
601 skt->socket = dead_socket;
602 skt->ops->init(skt);
603 skt->ops->set_socket(skt, &skt->socket);
604
605
606 ret = device_register(&skt->dev);
607 if (ret) {
608 dev_printk(KERN_WARNING, &skt->dev,
609 "PCMCIA: unable to register socket\n");
610 skt->thread = NULL;
611 complete(&skt->thread_done);
612 return 0;
613 }
614 ret = pccard_sysfs_add_socket(&skt->dev);
615 if (ret)
616 dev_warn(&skt->dev, "err %d adding socket attributes\n", ret);
617
618 complete(&skt->thread_done);
619
620
621 msleep(250);
622
623 set_freezable();
624 for (;;) {
625 unsigned long flags;
626 unsigned int events;
627 unsigned int sysfs_events;
628
629 set_current_state(TASK_INTERRUPTIBLE);
630
631 spin_lock_irqsave(&skt->thread_lock, flags);
632 events = skt->thread_events;
633 skt->thread_events = 0;
634 sysfs_events = skt->sysfs_events;
635 skt->sysfs_events = 0;
636 spin_unlock_irqrestore(&skt->thread_lock, flags);
637
638 mutex_lock(&skt->skt_mutex);
639 if (events & SS_DETECT)
640 socket_detect_change(skt);
641
642 if (sysfs_events) {
643 if (sysfs_events & PCMCIA_UEVENT_EJECT)
644 socket_remove(skt);
645 if (sysfs_events & PCMCIA_UEVENT_INSERT)
646 socket_insert(skt);
647 if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) &&
648 !(skt->state & SOCKET_CARDBUS)) {
649 if (skt->callback)
650 ret = skt->callback->suspend(skt);
651 else
652 ret = 0;
653 if (!ret) {
654 socket_suspend(skt);
655 msleep(100);
656 }
657 }
658 if ((sysfs_events & PCMCIA_UEVENT_RESUME) &&
659 !(skt->state & SOCKET_CARDBUS)) {
660 ret = socket_resume(skt);
661 if (!ret && skt->callback)
662 skt->callback->resume(skt);
663 }
664 if ((sysfs_events & PCMCIA_UEVENT_REQUERY) &&
665 !(skt->state & SOCKET_CARDBUS)) {
666 if (!ret && skt->callback)
667 skt->callback->requery(skt);
668 }
669 }
670 mutex_unlock(&skt->skt_mutex);
671
672 if (events || sysfs_events)
673 continue;
674
675 if (kthread_should_stop())
676 break;
677
678 schedule();
679 try_to_freeze();
680 }
681
682 set_current_state(TASK_RUNNING);
683
684
685 if (skt->state & SOCKET_PRESENT) {
686 mutex_lock(&skt->skt_mutex);
687 socket_remove(skt);
688 mutex_unlock(&skt->skt_mutex);
689 }
690
691
692 pccard_sysfs_remove_socket(&skt->dev);
693 device_unregister(&skt->dev);
694
695 return 0;
696}
697
698
699
700
701
702void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
703{
704 unsigned long flags;
705 dev_dbg(&s->dev, "parse_events: events %08x\n", events);
706 if (s->thread) {
707 spin_lock_irqsave(&s->thread_lock, flags);
708 s->thread_events |= events;
709 spin_unlock_irqrestore(&s->thread_lock, flags);
710
711 wake_up_process(s->thread);
712 }
713}
714EXPORT_SYMBOL(pcmcia_parse_events);
715
716
717
718
719
720
721
722
723
724
725
726
727void pcmcia_parse_uevents(struct pcmcia_socket *s, u_int events)
728{
729 unsigned long flags;
730 dev_dbg(&s->dev, "parse_uevents: events %08x\n", events);
731 if (s->thread) {
732 spin_lock_irqsave(&s->thread_lock, flags);
733 s->sysfs_events |= events;
734 spin_unlock_irqrestore(&s->thread_lock, flags);
735
736 wake_up_process(s->thread);
737 }
738}
739EXPORT_SYMBOL(pcmcia_parse_uevents);
740
741
742
743int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c)
744{
745 int ret = 0;
746
747
748 mutex_lock(&s->skt_mutex);
749
750 if (c) {
751
752 if (s->callback) {
753 ret = -EBUSY;
754 goto err;
755 }
756
757 s->callback = c;
758
759 if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT)
760 s->callback->add(s);
761 } else
762 s->callback = NULL;
763 err:
764 mutex_unlock(&s->skt_mutex);
765
766 return ret;
767}
768EXPORT_SYMBOL(pccard_register_pcmcia);
769
770
771
772
773
774
775
776int pcmcia_reset_card(struct pcmcia_socket *skt)
777{
778 int ret;
779
780 dev_dbg(&skt->dev, "resetting socket\n");
781
782 mutex_lock(&skt->skt_mutex);
783 do {
784 if (!(skt->state & SOCKET_PRESENT)) {
785 dev_dbg(&skt->dev, "can't reset, not present\n");
786 ret = -ENODEV;
787 break;
788 }
789 if (skt->state & SOCKET_SUSPEND) {
790 dev_dbg(&skt->dev, "can't reset, suspended\n");
791 ret = -EBUSY;
792 break;
793 }
794 if (skt->state & SOCKET_CARDBUS) {
795 dev_dbg(&skt->dev, "can't reset, is cardbus\n");
796 ret = -EPERM;
797 break;
798 }
799
800 if (skt->callback)
801 skt->callback->suspend(skt);
802 mutex_lock(&skt->ops_mutex);
803 ret = socket_reset(skt);
804 mutex_unlock(&skt->ops_mutex);
805 if ((ret == 0) && (skt->callback))
806 skt->callback->resume(skt);
807
808 ret = 0;
809 } while (0);
810 mutex_unlock(&skt->skt_mutex);
811
812 return ret;
813}
814EXPORT_SYMBOL(pcmcia_reset_card);
815
816
817static int pcmcia_socket_uevent(struct device *dev,
818 struct kobj_uevent_env *env)
819{
820 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
821
822 if (add_uevent_var(env, "SOCKET_NO=%u", s->sock))
823 return -ENOMEM;
824
825 return 0;
826}
827
828
829static struct completion pcmcia_unload;
830
831static void pcmcia_release_socket_class(struct class *data)
832{
833 complete(&pcmcia_unload);
834}
835
836
837#ifdef CONFIG_PM
838
839static int __pcmcia_pm_op(struct device *dev,
840 int (*callback) (struct pcmcia_socket *skt))
841{
842 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
843 int ret;
844
845 mutex_lock(&s->skt_mutex);
846 ret = callback(s);
847 mutex_unlock(&s->skt_mutex);
848
849 return ret;
850}
851
852static int pcmcia_socket_dev_suspend_noirq(struct device *dev)
853{
854 return __pcmcia_pm_op(dev, socket_suspend);
855}
856
857static int pcmcia_socket_dev_resume_noirq(struct device *dev)
858{
859 return __pcmcia_pm_op(dev, socket_early_resume);
860}
861
862static int __used pcmcia_socket_dev_resume(struct device *dev)
863{
864 return __pcmcia_pm_op(dev, socket_late_resume);
865}
866
867static void __used pcmcia_socket_dev_complete(struct device *dev)
868{
869 WARN(__pcmcia_pm_op(dev, socket_complete_resume),
870 "failed to complete resume");
871}
872
873static const struct dev_pm_ops pcmcia_socket_pm_ops = {
874
875 SET_SYSTEM_SLEEP_PM_OPS(NULL,
876 pcmcia_socket_dev_resume)
877
878
879 .suspend_noirq = pcmcia_socket_dev_suspend_noirq,
880 .freeze_noirq = pcmcia_socket_dev_suspend_noirq,
881 .poweroff_noirq = pcmcia_socket_dev_suspend_noirq,
882
883
884 .resume_noirq = pcmcia_socket_dev_resume_noirq,
885 .thaw_noirq = pcmcia_socket_dev_resume_noirq,
886 .restore_noirq = pcmcia_socket_dev_resume_noirq,
887 .complete = pcmcia_socket_dev_complete,
888};
889
890#define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops)
891
892#else
893
894#define PCMCIA_SOCKET_CLASS_PM_OPS NULL
895
896#endif
897
898struct class pcmcia_socket_class = {
899 .name = "pcmcia_socket",
900 .dev_uevent = pcmcia_socket_uevent,
901 .dev_release = pcmcia_release_socket,
902 .class_release = pcmcia_release_socket_class,
903 .pm = PCMCIA_SOCKET_CLASS_PM_OPS,
904};
905EXPORT_SYMBOL(pcmcia_socket_class);
906
907
908static int __init init_pcmcia_cs(void)
909{
910 init_completion(&pcmcia_unload);
911 return class_register(&pcmcia_socket_class);
912}
913
914static void __exit exit_pcmcia_cs(void)
915{
916 class_unregister(&pcmcia_socket_class);
917 wait_for_completion(&pcmcia_unload);
918}
919
920subsys_initcall(init_pcmcia_cs);
921module_exit(exit_pcmcia_cs);
922
923