15 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/string.h>
21 #include <linux/errno.h>
22 #include <linux/slab.h>
29 #include <linux/device.h>
47 #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)
93 static void pcmcia_release_socket(
struct device *
dev)
100 static int pccardd(
void *__skt);
114 dev_dbg(&socket->
dev,
"pcmcia_register_socket(0x%p)\n", socket->
ops);
124 unsigned int found,
i = 1;
134 socket->
sock = i - 1;
139 #ifndef CONFIG_CARDBUS
181 "PCMCIA: warning: socket thread did not start\n");
192 request_module_nowait(
"pcmcia");
214 dev_dbg(&socket->
dev,
"pcmcia_unregister_socket(0x%p)\n", socket->
ops);
265 msleep(unreset_delay * 10);
266 for (i = 0; i < unreset_limit; i++) {
267 skt->
ops->get_status(skt, &status);
275 msleep(unreset_check * 10);
278 dev_printk(
KERN_ERR, &skt->
dev,
"time out after reset.\n");
299 msleep(shutdown_delay * 10);
319 #ifdef CONFIG_CARDBUS
326 s->
ops->get_status(s, &status);
329 "*** DANGER *** unable to remove socket power\n");
335 static int socket_setup(
struct pcmcia_socket *skt,
int initial_delay)
341 skt->
ops->get_status(skt, &status);
345 msleep(initial_delay * 10);
347 for (i = 0; i < 100; i++) {
348 skt->
ops->get_status(skt, &status);
349 if (!(status & SS_DETECT))
360 "voltage interrogation timed out.\n");
367 "cardbus cards are not supported.\n");
382 dev_printk(
KERN_ERR, &skt->
dev,
"unsupported voltage key.\n");
397 skt->
ops->get_status(skt, &status);
399 dev_printk(
KERN_ERR, &skt->
dev,
"unable to apply power.\n");
403 status = socket_reset(skt);
428 ret = socket_setup(skt, setup_delay);
433 "pccard: %s card inserted into slot %d\n",
437 #ifdef CONFIG_CARDBUS
450 socket_shutdown(skt);
466 if (skt->
ops->suspend)
467 skt->
ops->suspend(skt);
494 ret = socket_insert(skt);
501 socket_shutdown(skt);
507 "suspend state 0x%x != resume state 0x%x\n",
510 socket_shutdown(skt);
511 return socket_insert(skt);
514 #ifdef CONFIG_CARDBUS
539 socket_early_resume(skt);
540 return socket_late_resume(skt);
546 "pccard: card ejected from slot %d\n", skt->
sock);
547 socket_shutdown(skt);
569 skt->
ops->get_status(skt, &status);
571 !(status & SS_DETECT))
574 (status & SS_DETECT))
579 static int pccardd(
void *__skt)
593 "PCMCIA: unable to register socket\n");
600 dev_warn(&skt->
dev,
"err %d adding socket attributes\n", ret);
623 if (events & SS_DETECT)
624 socket_detect_change(skt);
644 ret = socket_resume(skt);
656 if (events || sysfs_events)
689 dev_dbg(&s->
dev,
"parse_events: events %08x\n", events);
714 dev_dbg(&s->
dev,
"parse_uevents: events %08x\n", events);
769 dev_dbg(&skt->
dev,
"can't reset, not present\n");
774 dev_dbg(&skt->
dev,
"can't reset, suspended\n");
779 dev_dbg(&skt->
dev,
"can't reset, is cardbus\n");
787 ret = socket_reset(skt);
801 static int pcmcia_socket_uevent(
struct device *
dev,
815 static void pcmcia_release_socket_class(
struct class *
data)
823 static int __pcmcia_pm_op(
struct device *dev,
836 static int pcmcia_socket_dev_suspend_noirq(
struct device *dev)
838 return __pcmcia_pm_op(dev, socket_suspend);
841 static int pcmcia_socket_dev_resume_noirq(
struct device *dev)
843 return __pcmcia_pm_op(dev, socket_early_resume);
846 static int __used pcmcia_socket_dev_resume(
struct device *dev)
848 return __pcmcia_pm_op(dev, socket_late_resume);
851 static const struct dev_pm_ops pcmcia_socket_pm_ops = {
854 pcmcia_socket_dev_resume)
857 .suspend_noirq = pcmcia_socket_dev_suspend_noirq,
858 .freeze_noirq = pcmcia_socket_dev_suspend_noirq,
859 .poweroff_noirq = pcmcia_socket_dev_suspend_noirq,
862 .resume_noirq = pcmcia_socket_dev_resume_noirq,
863 .thaw_noirq = pcmcia_socket_dev_resume_noirq,
864 .restore_noirq = pcmcia_socket_dev_resume_noirq,
867 #define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops)
871 #define PCMCIA_SOCKET_CLASS_PM_OPS NULL
876 .name =
"pcmcia_socket",
877 .dev_uevent = pcmcia_socket_uevent,
878 .dev_release = pcmcia_release_socket,
879 .class_release = pcmcia_release_socket_class,
885 static int __init init_pcmcia_cs(
void)
887 init_completion(&pcmcia_unload);
891 static void __exit exit_pcmcia_cs(
void)