2 * cs.c -- Kernel Card Services - core services
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
12 * (C) 1999 David A. Hinds
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>
24 #include <linux/interrupt.h>
25 #include <linux/timer.h>
26 #include <linux/ioport.h>
27 #include <linux/delay.h>
29 #include <linux/device.h>
30 #include <linux/kthread.h>
31 #include <linux/freezer.h>
32 #include <asm/system.h>
35 #include <pcmcia/ss.h>
36 #include <pcmcia/cs.h>
37 #include <pcmcia/cistpl.h>
38 #include <pcmcia/cisreg.h>
39 #include <pcmcia/ds.h>
40 #include "cs_internal.h"
43 /* Module parameters */
45 MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
46 MODULE_DESCRIPTION("Linux Kernel Card Services");
47 MODULE_LICENSE("GPL");
49 #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
51 INT_MODULE_PARM(setup_delay
, 10); /* centiseconds */
52 INT_MODULE_PARM(resume_delay
, 20); /* centiseconds */
53 INT_MODULE_PARM(shutdown_delay
, 3); /* centiseconds */
54 INT_MODULE_PARM(vcc_settle
, 40); /* centiseconds */
55 INT_MODULE_PARM(reset_time
, 10); /* usecs */
56 INT_MODULE_PARM(unreset_delay
, 10); /* centiseconds */
57 INT_MODULE_PARM(unreset_check
, 10); /* centiseconds */
58 INT_MODULE_PARM(unreset_limit
, 30); /* unreset_check's */
60 /* Access speed for attribute memory windows */
61 INT_MODULE_PARM(cis_speed
, 300); /* ns */
64 socket_state_t dead_socket
= {
65 .csc_mask
= SS_DETECT
,
67 EXPORT_SYMBOL(dead_socket
);
70 /* List of all sockets, protected by a rwsem */
71 LIST_HEAD(pcmcia_socket_list
);
72 EXPORT_SYMBOL(pcmcia_socket_list
);
74 DECLARE_RWSEM(pcmcia_socket_list_rwsem
);
75 EXPORT_SYMBOL(pcmcia_socket_list_rwsem
);
78 struct pcmcia_socket
*pcmcia_get_socket(struct pcmcia_socket
*skt
)
80 struct device
*dev
= get_device(&skt
->dev
);
83 return dev_get_drvdata(dev
);
85 EXPORT_SYMBOL(pcmcia_get_socket
);
88 void pcmcia_put_socket(struct pcmcia_socket
*skt
)
90 put_device(&skt
->dev
);
92 EXPORT_SYMBOL(pcmcia_put_socket
);
95 static void pcmcia_release_socket(struct device
*dev
)
97 struct pcmcia_socket
*socket
= dev_get_drvdata(dev
);
99 complete(&socket
->socket_released
);
102 static int pccardd(void *__skt
);
105 * pcmcia_register_socket - add a new pcmcia socket device
106 * @socket: the &socket to register
108 int pcmcia_register_socket(struct pcmcia_socket
*socket
)
110 struct task_struct
*tsk
;
113 if (!socket
|| !socket
->ops
|| !socket
->dev
.parent
|| !socket
->resource_ops
)
116 dev_dbg(&socket
->dev
, "pcmcia_register_socket(0x%p)\n", socket
->ops
);
118 /* try to obtain a socket number [yes, it gets ugly if we
119 * register more than 2^sizeof(unsigned int) pcmcia
120 * sockets... but the socket number is deprecated
121 * anyways, so I don't care] */
122 down_write(&pcmcia_socket_list_rwsem
);
123 if (list_empty(&pcmcia_socket_list
))
126 unsigned int found
, i
= 1;
127 struct pcmcia_socket
*tmp
;
130 list_for_each_entry(tmp
, &pcmcia_socket_list
, socket_list
) {
136 socket
->sock
= i
- 1;
138 list_add_tail(&socket
->socket_list
, &pcmcia_socket_list
);
139 up_write(&pcmcia_socket_list_rwsem
);
141 #ifndef CONFIG_CARDBUS
143 * If we do not support Cardbus, ensure that
144 * the Cardbus socket capability is disabled.
146 socket
->features
&= ~SS_CAP_CARDBUS
;
149 /* set proper values in socket->dev */
150 dev_set_drvdata(&socket
->dev
, socket
);
151 socket
->dev
.class = &pcmcia_socket_class
;
152 dev_set_name(&socket
->dev
, "pcmcia_socket%u", socket
->sock
);
154 /* base address = 0, map = 0 */
155 socket
->cis_mem
.flags
= 0;
156 socket
->cis_mem
.speed
= cis_speed
;
158 INIT_LIST_HEAD(&socket
->cis_cache
);
160 init_completion(&socket
->socket_released
);
161 init_completion(&socket
->thread_done
);
162 mutex_init(&socket
->skt_mutex
);
163 mutex_init(&socket
->ops_mutex
);
164 spin_lock_init(&socket
->thread_lock
);
166 if (socket
->resource_ops
->init
) {
167 mutex_lock(&socket
->ops_mutex
);
168 ret
= socket
->resource_ops
->init(socket
);
169 mutex_unlock(&socket
->ops_mutex
);
174 tsk
= kthread_run(pccardd
, socket
, "pccardd");
180 wait_for_completion(&socket
->thread_done
);
181 if (!socket
->thread
) {
182 dev_printk(KERN_WARNING
, &socket
->dev
,
183 "PCMCIA: warning: socket thread did not start\n");
187 pcmcia_parse_events(socket
, SS_DETECT
);
190 * Let's try to get the PCMCIA module for 16-bit PCMCIA support.
191 * If it fails, it doesn't matter -- we still have 32-bit CardBus
192 * support to offer, so this is not a failure mode.
194 request_module_nowait("pcmcia");
199 down_write(&pcmcia_socket_list_rwsem
);
200 list_del(&socket
->socket_list
);
201 up_write(&pcmcia_socket_list_rwsem
);
203 } /* pcmcia_register_socket */
204 EXPORT_SYMBOL(pcmcia_register_socket
);
208 * pcmcia_unregister_socket - remove a pcmcia socket device
209 * @socket: the &socket to unregister
211 void pcmcia_unregister_socket(struct pcmcia_socket
*socket
)
216 dev_dbg(&socket
->dev
, "pcmcia_unregister_socket(0x%p)\n", socket
->ops
);
219 kthread_stop(socket
->thread
);
221 /* remove from our own list */
222 down_write(&pcmcia_socket_list_rwsem
);
223 list_del(&socket
->socket_list
);
224 up_write(&pcmcia_socket_list_rwsem
);
226 /* wait for sysfs to drop all references */
227 if (socket
->resource_ops
->exit
) {
228 mutex_lock(&socket
->ops_mutex
);
229 socket
->resource_ops
->exit(socket
);
230 mutex_unlock(&socket
->ops_mutex
);
232 wait_for_completion(&socket
->socket_released
);
233 } /* pcmcia_unregister_socket */
234 EXPORT_SYMBOL(pcmcia_unregister_socket
);
237 struct pcmcia_socket
*pcmcia_get_socket_by_nr(unsigned int nr
)
239 struct pcmcia_socket
*s
;
241 down_read(&pcmcia_socket_list_rwsem
);
242 list_for_each_entry(s
, &pcmcia_socket_list
, socket_list
)
244 up_read(&pcmcia_socket_list_rwsem
);
247 up_read(&pcmcia_socket_list_rwsem
);
252 EXPORT_SYMBOL(pcmcia_get_socket_by_nr
);
254 static int socket_reset(struct pcmcia_socket
*skt
)
258 dev_dbg(&skt
->dev
, "reset\n");
260 skt
->socket
.flags
|= SS_OUTPUT_ENA
| SS_RESET
;
261 skt
->ops
->set_socket(skt
, &skt
->socket
);
262 udelay((long)reset_time
);
264 skt
->socket
.flags
&= ~SS_RESET
;
265 skt
->ops
->set_socket(skt
, &skt
->socket
);
267 msleep(unreset_delay
* 10);
268 for (i
= 0; i
< unreset_limit
; i
++) {
269 skt
->ops
->get_status(skt
, &status
);
271 if (!(status
& SS_DETECT
))
274 if (status
& SS_READY
)
277 msleep(unreset_check
* 10);
280 dev_printk(KERN_ERR
, &skt
->dev
, "time out after reset.\n");
285 * socket_setup() and socket_shutdown() are called by the main event handler
286 * when card insertion and removal events are received.
287 * socket_setup() turns on socket power and resets the socket, in two stages.
288 * socket_shutdown() unconfigures a socket and turns off socket power.
290 static void socket_shutdown(struct pcmcia_socket
*s
)
294 dev_dbg(&s
->dev
, "shutdown\n");
297 s
->callback
->remove(s
);
299 mutex_lock(&s
->ops_mutex
);
300 s
->state
&= SOCKET_INUSE
| SOCKET_PRESENT
;
301 msleep(shutdown_delay
* 10);
302 s
->state
&= SOCKET_INUSE
;
304 /* Blank out the socket state */
305 s
->socket
= dead_socket
;
307 s
->ops
->set_socket(s
, &s
->socket
);
313 /* From here on we can be sure that only we (that is, the
314 * pccardd thread) accesses this socket, and all (16-bit)
315 * PCMCIA interactions are gone. Therefore, release
316 * ops_mutex so that we don't get a sysfs-related lockdep
319 mutex_unlock(&s
->ops_mutex
);
321 #ifdef CONFIG_CARDBUS
325 /* give socket some time to power down */
328 s
->ops
->get_status(s
, &status
);
329 if (status
& SS_POWERON
) {
330 dev_printk(KERN_ERR
, &s
->dev
,
331 "*** DANGER *** unable to remove socket power\n");
334 s
->state
&= ~SOCKET_INUSE
;
337 static int socket_setup(struct pcmcia_socket
*skt
, int initial_delay
)
341 dev_dbg(&skt
->dev
, "setup\n");
343 skt
->ops
->get_status(skt
, &status
);
344 if (!(status
& SS_DETECT
))
347 msleep(initial_delay
* 10);
349 for (i
= 0; i
< 100; i
++) {
350 skt
->ops
->get_status(skt
, &status
);
351 if (!(status
& SS_DETECT
))
354 if (!(status
& SS_PENDING
))
360 if (status
& SS_PENDING
) {
361 dev_printk(KERN_ERR
, &skt
->dev
,
362 "voltage interrogation timed out.\n");
366 if (status
& SS_CARDBUS
) {
367 if (!(skt
->features
& SS_CAP_CARDBUS
)) {
368 dev_printk(KERN_ERR
, &skt
->dev
,
369 "cardbus cards are not supported.\n");
372 skt
->state
|= SOCKET_CARDBUS
;
374 skt
->state
&= ~SOCKET_CARDBUS
;
377 * Decode the card voltage requirements, and apply power to the card.
379 if (status
& SS_3VCARD
)
380 skt
->socket
.Vcc
= skt
->socket
.Vpp
= 33;
381 else if (!(status
& SS_XVCARD
))
382 skt
->socket
.Vcc
= skt
->socket
.Vpp
= 50;
384 dev_printk(KERN_ERR
, &skt
->dev
, "unsupported voltage key.\n");
389 skt
->power_hook(skt
, HOOK_POWER_PRE
);
391 skt
->socket
.flags
= 0;
392 skt
->ops
->set_socket(skt
, &skt
->socket
);
395 * Wait "vcc_settle" for the supply to stabilise.
397 msleep(vcc_settle
* 10);
399 skt
->ops
->get_status(skt
, &status
);
400 if (!(status
& SS_POWERON
)) {
401 dev_printk(KERN_ERR
, &skt
->dev
, "unable to apply power.\n");
405 status
= socket_reset(skt
);
408 skt
->power_hook(skt
, HOOK_POWER_POST
);
414 * Handle card insertion. Setup the socket, reset the card,
415 * and then tell the rest of PCMCIA that a card is present.
417 static int socket_insert(struct pcmcia_socket
*skt
)
421 dev_dbg(&skt
->dev
, "insert\n");
423 mutex_lock(&skt
->ops_mutex
);
424 if (skt
->state
& SOCKET_INUSE
) {
425 mutex_unlock(&skt
->ops_mutex
);
428 skt
->state
|= SOCKET_INUSE
;
430 ret
= socket_setup(skt
, setup_delay
);
432 skt
->state
|= SOCKET_PRESENT
;
434 dev_printk(KERN_NOTICE
, &skt
->dev
,
435 "pccard: %s card inserted into slot %d\n",
436 (skt
->state
& SOCKET_CARDBUS
) ? "CardBus" : "PCMCIA",
439 #ifdef CONFIG_CARDBUS
440 if (skt
->state
& SOCKET_CARDBUS
) {
442 skt
->state
|= SOCKET_CARDBUS_CONFIG
;
445 dev_dbg(&skt
->dev
, "insert done\n");
446 mutex_unlock(&skt
->ops_mutex
);
448 if (!(skt
->state
& SOCKET_CARDBUS
) && (skt
->callback
))
449 skt
->callback
->add(skt
);
451 mutex_unlock(&skt
->ops_mutex
);
452 socket_shutdown(skt
);
458 static int socket_suspend(struct pcmcia_socket
*skt
)
460 if (skt
->state
& SOCKET_SUSPEND
)
463 mutex_lock(&skt
->ops_mutex
);
464 skt
->suspended_state
= skt
->state
;
466 skt
->socket
= dead_socket
;
467 skt
->ops
->set_socket(skt
, &skt
->socket
);
468 if (skt
->ops
->suspend
)
469 skt
->ops
->suspend(skt
);
470 skt
->state
|= SOCKET_SUSPEND
;
471 mutex_unlock(&skt
->ops_mutex
);
475 static int socket_early_resume(struct pcmcia_socket
*skt
)
477 mutex_lock(&skt
->ops_mutex
);
478 skt
->socket
= dead_socket
;
480 skt
->ops
->set_socket(skt
, &skt
->socket
);
481 if (skt
->state
& SOCKET_PRESENT
)
482 skt
->resume_status
= socket_setup(skt
, resume_delay
);
483 mutex_unlock(&skt
->ops_mutex
);
487 static int socket_late_resume(struct pcmcia_socket
*skt
)
491 mutex_lock(&skt
->ops_mutex
);
492 skt
->state
&= ~SOCKET_SUSPEND
;
493 mutex_unlock(&skt
->ops_mutex
);
495 if (!(skt
->state
& SOCKET_PRESENT
)) {
496 ret
= socket_insert(skt
);
502 if (skt
->resume_status
) {
503 socket_shutdown(skt
);
507 if (skt
->suspended_state
!= skt
->state
) {
509 "suspend state 0x%x != resume state 0x%x\n",
510 skt
->suspended_state
, skt
->state
);
512 socket_shutdown(skt
);
513 return socket_insert(skt
);
516 #ifdef CONFIG_CARDBUS
517 if (skt
->state
& SOCKET_CARDBUS
) {
518 /* We can't be sure the CardBus card is the same
519 * as the one previously inserted. Therefore, remove
526 if (!(skt
->state
& SOCKET_CARDBUS
) && (skt
->callback
))
527 skt
->callback
->early_resume(skt
);
532 * Resume a socket. If a card is present, verify its CIS against
533 * our cached copy. If they are different, the card has been
534 * replaced, and we need to tell the drivers.
536 static int socket_resume(struct pcmcia_socket
*skt
)
538 if (!(skt
->state
& SOCKET_SUSPEND
))
541 socket_early_resume(skt
);
542 return socket_late_resume(skt
);
545 static void socket_remove(struct pcmcia_socket
*skt
)
547 dev_printk(KERN_NOTICE
, &skt
->dev
,
548 "pccard: card ejected from slot %d\n", skt
->sock
);
549 socket_shutdown(skt
);
553 * Process a socket card detect status change.
555 * If we don't have a card already present, delay the detect event for
556 * about 20ms (to be on the safe side) before reading the socket status.
558 * Some i82365-based systems send multiple SS_DETECT events during card
559 * insertion, and the "card present" status bit seems to bounce. This
560 * will probably be true with GPIO-based card detection systems after
561 * the product has aged.
563 static void socket_detect_change(struct pcmcia_socket
*skt
)
565 if (!(skt
->state
& SOCKET_SUSPEND
)) {
568 if (!(skt
->state
& SOCKET_PRESENT
))
571 skt
->ops
->get_status(skt
, &status
);
572 if ((skt
->state
& SOCKET_PRESENT
) &&
573 !(status
& SS_DETECT
))
575 if (!(skt
->state
& SOCKET_PRESENT
) &&
576 (status
& SS_DETECT
))
581 static int pccardd(void *__skt
)
583 struct pcmcia_socket
*skt
= __skt
;
586 skt
->thread
= current
;
587 skt
->socket
= dead_socket
;
589 skt
->ops
->set_socket(skt
, &skt
->socket
);
591 /* register with the device core */
592 ret
= device_register(&skt
->dev
);
594 dev_printk(KERN_WARNING
, &skt
->dev
,
595 "PCMCIA: unable to register socket\n");
597 complete(&skt
->thread_done
);
600 ret
= pccard_sysfs_add_socket(&skt
->dev
);
602 dev_warn(&skt
->dev
, "err %d adding socket attributes\n", ret
);
604 complete(&skt
->thread_done
);
606 /* wait for userspace to catch up */
613 unsigned int sysfs_events
;
615 set_current_state(TASK_INTERRUPTIBLE
);
617 spin_lock_irqsave(&skt
->thread_lock
, flags
);
618 events
= skt
->thread_events
;
619 skt
->thread_events
= 0;
620 sysfs_events
= skt
->sysfs_events
;
621 skt
->sysfs_events
= 0;
622 spin_unlock_irqrestore(&skt
->thread_lock
, flags
);
624 mutex_lock(&skt
->skt_mutex
);
625 if (events
& SS_DETECT
)
626 socket_detect_change(skt
);
629 if (sysfs_events
& PCMCIA_UEVENT_EJECT
)
631 if (sysfs_events
& PCMCIA_UEVENT_INSERT
)
633 if ((sysfs_events
& PCMCIA_UEVENT_SUSPEND
) &&
634 !(skt
->state
& SOCKET_CARDBUS
)) {
636 ret
= skt
->callback
->suspend(skt
);
644 if ((sysfs_events
& PCMCIA_UEVENT_RESUME
) &&
645 !(skt
->state
& SOCKET_CARDBUS
)) {
646 ret
= socket_resume(skt
);
647 if (!ret
&& skt
->callback
)
648 skt
->callback
->resume(skt
);
650 if ((sysfs_events
& PCMCIA_UEVENT_REQUERY
) &&
651 !(skt
->state
& SOCKET_CARDBUS
)) {
652 if (!ret
&& skt
->callback
)
653 skt
->callback
->requery(skt
);
656 mutex_unlock(&skt
->skt_mutex
);
658 if (events
|| sysfs_events
)
661 if (kthread_should_stop())
667 /* make sure we are running before we exit */
668 set_current_state(TASK_RUNNING
);
670 /* shut down socket, if a device is still present */
671 if (skt
->state
& SOCKET_PRESENT
) {
672 mutex_lock(&skt
->skt_mutex
);
674 mutex_unlock(&skt
->skt_mutex
);
677 /* remove from the device core */
678 pccard_sysfs_remove_socket(&skt
->dev
);
679 device_unregister(&skt
->dev
);
685 * Yenta (at least) probes interrupts before registering the socket and
686 * starting the handler thread.
688 void pcmcia_parse_events(struct pcmcia_socket
*s
, u_int events
)
691 dev_dbg(&s
->dev
, "parse_events: events %08x\n", events
);
693 spin_lock_irqsave(&s
->thread_lock
, flags
);
694 s
->thread_events
|= events
;
695 spin_unlock_irqrestore(&s
->thread_lock
, flags
);
697 wake_up_process(s
->thread
);
699 } /* pcmcia_parse_events */
700 EXPORT_SYMBOL(pcmcia_parse_events
);
703 * pcmcia_parse_uevents() - tell pccardd to issue manual commands
704 * @s: the PCMCIA socket we wan't to command
705 * @events: events to pass to pccardd
707 * userspace-issued insert, eject, suspend and resume commands must be
708 * handled by pccardd to avoid any sysfs-related deadlocks. Valid events
709 * are PCMCIA_UEVENT_EJECT (for eject), PCMCIA_UEVENT__INSERT (for insert),
710 * PCMCIA_UEVENT_RESUME (for resume), PCMCIA_UEVENT_SUSPEND (for suspend)
711 * and PCMCIA_UEVENT_REQUERY (for re-querying the PCMCIA card).
713 void pcmcia_parse_uevents(struct pcmcia_socket
*s
, u_int events
)
716 dev_dbg(&s
->dev
, "parse_uevents: events %08x\n", events
);
718 spin_lock_irqsave(&s
->thread_lock
, flags
);
719 s
->sysfs_events
|= events
;
720 spin_unlock_irqrestore(&s
->thread_lock
, flags
);
722 wake_up_process(s
->thread
);
725 EXPORT_SYMBOL(pcmcia_parse_uevents
);
728 /* register pcmcia_callback */
729 int pccard_register_pcmcia(struct pcmcia_socket
*s
, struct pcmcia_callback
*c
)
733 /* s->skt_mutex also protects s->callback */
734 mutex_lock(&s
->skt_mutex
);
745 if ((s
->state
& (SOCKET_PRESENT
|SOCKET_CARDBUS
)) == SOCKET_PRESENT
)
750 mutex_unlock(&s
->skt_mutex
);
754 EXPORT_SYMBOL(pccard_register_pcmcia
);
757 /* I'm not sure which "reset" function this is supposed to use,
758 * but for now, it uses the low-level interface's reset, not the
762 int pcmcia_reset_card(struct pcmcia_socket
*skt
)
766 dev_dbg(&skt
->dev
, "resetting socket\n");
768 mutex_lock(&skt
->skt_mutex
);
770 if (!(skt
->state
& SOCKET_PRESENT
)) {
771 dev_dbg(&skt
->dev
, "can't reset, not present\n");
775 if (skt
->state
& SOCKET_SUSPEND
) {
776 dev_dbg(&skt
->dev
, "can't reset, suspended\n");
780 if (skt
->state
& SOCKET_CARDBUS
) {
781 dev_dbg(&skt
->dev
, "can't reset, is cardbus\n");
787 skt
->callback
->suspend(skt
);
788 mutex_lock(&skt
->ops_mutex
);
789 ret
= socket_reset(skt
);
790 mutex_unlock(&skt
->ops_mutex
);
791 if ((ret
== 0) && (skt
->callback
))
792 skt
->callback
->resume(skt
);
796 mutex_unlock(&skt
->skt_mutex
);
800 EXPORT_SYMBOL(pcmcia_reset_card
);
803 static int pcmcia_socket_uevent(struct device
*dev
,
804 struct kobj_uevent_env
*env
)
806 struct pcmcia_socket
*s
= container_of(dev
, struct pcmcia_socket
, dev
);
808 if (add_uevent_var(env
, "SOCKET_NO=%u", s
->sock
))
815 static struct completion pcmcia_unload
;
817 static void pcmcia_release_socket_class(struct class *data
)
819 complete(&pcmcia_unload
);
825 static int __pcmcia_pm_op(struct device
*dev
,
826 int (*callback
) (struct pcmcia_socket
*skt
))
828 struct pcmcia_socket
*s
= container_of(dev
, struct pcmcia_socket
, dev
);
831 mutex_lock(&s
->skt_mutex
);
833 mutex_unlock(&s
->skt_mutex
);
838 static int pcmcia_socket_dev_suspend_noirq(struct device
*dev
)
840 return __pcmcia_pm_op(dev
, socket_suspend
);
843 static int pcmcia_socket_dev_resume_noirq(struct device
*dev
)
845 return __pcmcia_pm_op(dev
, socket_early_resume
);
848 static int pcmcia_socket_dev_resume(struct device
*dev
)
850 return __pcmcia_pm_op(dev
, socket_late_resume
);
853 static const struct dev_pm_ops pcmcia_socket_pm_ops
= {
854 /* dev_resume may be called with IRQs enabled */
855 SET_SYSTEM_SLEEP_PM_OPS(NULL
,
856 pcmcia_socket_dev_resume
)
858 /* late suspend must be called with IRQs disabled */
859 .suspend_noirq
= pcmcia_socket_dev_suspend_noirq
,
860 .freeze_noirq
= pcmcia_socket_dev_suspend_noirq
,
861 .poweroff_noirq
= pcmcia_socket_dev_suspend_noirq
,
863 /* early resume must be called with IRQs disabled */
864 .resume_noirq
= pcmcia_socket_dev_resume_noirq
,
865 .thaw_noirq
= pcmcia_socket_dev_resume_noirq
,
866 .restore_noirq
= pcmcia_socket_dev_resume_noirq
,
869 #define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops)
871 #else /* CONFIG_PM */
873 #define PCMCIA_SOCKET_CLASS_PM_OPS NULL
875 #endif /* CONFIG_PM */
877 struct class pcmcia_socket_class
= {
878 .name
= "pcmcia_socket",
879 .dev_uevent
= pcmcia_socket_uevent
,
880 .dev_release
= pcmcia_release_socket
,
881 .class_release
= pcmcia_release_socket_class
,
882 .pm
= PCMCIA_SOCKET_CLASS_PM_OPS
,
884 EXPORT_SYMBOL(pcmcia_socket_class
);
887 static int __init
init_pcmcia_cs(void)
889 init_completion(&pcmcia_unload
);
890 return class_register(&pcmcia_socket_class
);
893 static void __exit
exit_pcmcia_cs(void)
895 class_unregister(&pcmcia_socket_class
);
896 wait_for_completion(&pcmcia_unload
);
899 subsys_initcall(init_pcmcia_cs
);
900 module_exit(exit_pcmcia_cs
);