diff options
-rw-r--r-- | drivers/pcmcia/cistpl.c | 1 | ||||
-rw-r--r-- | drivers/pcmcia/cs.c | 209 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 10 |
3 files changed, 76 insertions, 144 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index a8aa7b9cf641..8567f4fad501 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
@@ -385,6 +385,7 @@ int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) | |||
385 | memcpy(s->fake_cis, cis->Data, cis->Length); | 385 | memcpy(s->fake_cis, cis->Data, cis->Length); |
386 | return CS_SUCCESS; | 386 | return CS_SUCCESS; |
387 | } | 387 | } |
388 | EXPORT_SYMBOL(pcmcia_replace_cis); | ||
388 | 389 | ||
389 | /*====================================================================== | 390 | /*====================================================================== |
390 | 391 | ||
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 6a35a4a9f932..0ff4d6ec8b77 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c | |||
@@ -43,36 +43,11 @@ | |||
43 | #include <pcmcia/ds.h> | 43 | #include <pcmcia/ds.h> |
44 | #include "cs_internal.h" | 44 | #include "cs_internal.h" |
45 | 45 | ||
46 | #ifdef CONFIG_PCI | ||
47 | #define PCI_OPT " [pci]" | ||
48 | #else | ||
49 | #define PCI_OPT "" | ||
50 | #endif | ||
51 | #ifdef CONFIG_CARDBUS | ||
52 | #define CB_OPT " [cardbus]" | ||
53 | #else | ||
54 | #define CB_OPT "" | ||
55 | #endif | ||
56 | #ifdef CONFIG_PM | ||
57 | #define PM_OPT " [pm]" | ||
58 | #else | ||
59 | #define PM_OPT "" | ||
60 | #endif | ||
61 | #if !defined(CONFIG_CARDBUS) && !defined(CONFIG_PCI) && !defined(CONFIG_PM) | ||
62 | #define OPTIONS " none" | ||
63 | #else | ||
64 | #define OPTIONS PCI_OPT CB_OPT PM_OPT | ||
65 | #endif | ||
66 | |||
67 | static const char *release = "Linux Kernel Card Services"; | ||
68 | static const char *options = "options: " OPTIONS; | ||
69 | |||
70 | /*====================================================================*/ | ||
71 | 46 | ||
72 | /* Module parameters */ | 47 | /* Module parameters */ |
73 | 48 | ||
74 | MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); | 49 | MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>"); |
75 | MODULE_DESCRIPTION("Linux Kernel Card Services\noptions:" OPTIONS); | 50 | MODULE_DESCRIPTION("Linux Kernel Card Services"); |
76 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
77 | 52 | ||
78 | #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) | 53 | #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) |
@@ -100,29 +75,26 @@ int cs_debug_level(int level) | |||
100 | } | 75 | } |
101 | #endif | 76 | #endif |
102 | 77 | ||
103 | /*====================================================================*/ | ||
104 | 78 | ||
105 | socket_state_t dead_socket = { | 79 | socket_state_t dead_socket = { |
106 | .csc_mask = SS_DETECT, | 80 | .csc_mask = SS_DETECT, |
107 | }; | 81 | }; |
82 | EXPORT_SYMBOL(dead_socket); | ||
108 | 83 | ||
109 | 84 | ||
110 | /* List of all sockets, protected by a rwsem */ | 85 | /* List of all sockets, protected by a rwsem */ |
111 | LIST_HEAD(pcmcia_socket_list); | 86 | LIST_HEAD(pcmcia_socket_list); |
112 | DECLARE_RWSEM(pcmcia_socket_list_rwsem); | ||
113 | EXPORT_SYMBOL(pcmcia_socket_list); | 87 | EXPORT_SYMBOL(pcmcia_socket_list); |
114 | EXPORT_SYMBOL(pcmcia_socket_list_rwsem); | ||
115 | 88 | ||
89 | DECLARE_RWSEM(pcmcia_socket_list_rwsem); | ||
90 | EXPORT_SYMBOL(pcmcia_socket_list_rwsem); | ||
116 | 91 | ||
117 | /*==================================================================== | ||
118 | |||
119 | Low-level PC Card interface drivers need to register with Card | ||
120 | Services using these calls. | ||
121 | |||
122 | ======================================================================*/ | ||
123 | 92 | ||
124 | /** | 93 | /** |
125 | * socket drivers are expected to use the following callbacks in their | 94 | * Low-level PCMCIA socket drivers need to register with the PCCard |
95 | * core using pcmcia_register_socket. | ||
96 | * | ||
97 | * socket drivers are expected to use the following callbacks in their | ||
126 | * .drv struct: | 98 | * .drv struct: |
127 | * - pcmcia_socket_dev_suspend | 99 | * - pcmcia_socket_dev_suspend |
128 | * - pcmcia_socket_dev_resume | 100 | * - pcmcia_socket_dev_resume |
@@ -222,8 +194,8 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) | |||
222 | } | 194 | } |
223 | 195 | ||
224 | /* try to obtain a socket number [yes, it gets ugly if we | 196 | /* try to obtain a socket number [yes, it gets ugly if we |
225 | * register more than 2^sizeof(unsigned int) pcmcia | 197 | * register more than 2^sizeof(unsigned int) pcmcia |
226 | * sockets... but the socket number is deprecated | 198 | * sockets... but the socket number is deprecated |
227 | * anyways, so I don't care] */ | 199 | * anyways, so I don't care] */ |
228 | down_write(&pcmcia_socket_list_rwsem); | 200 | down_write(&pcmcia_socket_list_rwsem); |
229 | if (list_empty(&pcmcia_socket_list)) | 201 | if (list_empty(&pcmcia_socket_list)) |
@@ -332,54 +304,49 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr) | |||
332 | EXPORT_SYMBOL(pcmcia_get_socket_by_nr); | 304 | EXPORT_SYMBOL(pcmcia_get_socket_by_nr); |
333 | 305 | ||
334 | 306 | ||
335 | /*====================================================================== | 307 | /** |
336 | 308 | * socket_setup() and shutdown_socket() are called by the main event | |
337 | socket_setup() and shutdown_socket() are called by the main event | 309 | * handler when card insertion and removal events are received. |
338 | handler when card insertion and removal events are received. | 310 | * socket_setup() turns on socket power and resets the socket, in two stages. |
339 | socket_setup() turns on socket power and resets the socket, in two stages. | 311 | * shutdown_socket() unconfigures a socket and turns off socket power. |
340 | shutdown_socket() unconfigures a socket and turns off socket power. | 312 | */ |
341 | |||
342 | ======================================================================*/ | ||
343 | |||
344 | static void shutdown_socket(struct pcmcia_socket *s) | 313 | static void shutdown_socket(struct pcmcia_socket *s) |
345 | { | 314 | { |
346 | cs_dbg(s, 1, "shutdown_socket\n"); | 315 | cs_dbg(s, 1, "shutdown_socket\n"); |
347 | 316 | ||
348 | /* Blank out the socket state */ | 317 | /* Blank out the socket state */ |
349 | s->socket = dead_socket; | 318 | s->socket = dead_socket; |
350 | s->ops->init(s); | 319 | s->ops->init(s); |
351 | s->ops->set_socket(s, &s->socket); | 320 | s->ops->set_socket(s, &s->socket); |
352 | s->irq.AssignedIRQ = s->irq.Config = 0; | 321 | s->irq.AssignedIRQ = s->irq.Config = 0; |
353 | s->lock_count = 0; | 322 | s->lock_count = 0; |
354 | destroy_cis_cache(s); | 323 | destroy_cis_cache(s); |
355 | #ifdef CONFIG_CARDBUS | 324 | #ifdef CONFIG_CARDBUS |
356 | cb_free(s); | 325 | cb_free(s); |
357 | #endif | 326 | #endif |
358 | s->functions = 0; | 327 | s->functions = 0; |
359 | if (s->config) { | 328 | if (s->config) { |
360 | kfree(s->config); | 329 | kfree(s->config); |
361 | s->config = NULL; | 330 | s->config = NULL; |
362 | } | ||
363 | |||
364 | { | ||
365 | int status; | ||
366 | s->ops->get_status(s, &status); | ||
367 | if (status & SS_POWERON) { | ||
368 | printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); | ||
369 | } | 331 | } |
370 | } | ||
371 | } /* shutdown_socket */ | ||
372 | 332 | ||
373 | /*====================================================================== | 333 | { |
334 | int status; | ||
335 | s->ops->get_status(s, &status); | ||
336 | if (status & SS_POWERON) { | ||
337 | printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); | ||
338 | } | ||
339 | } | ||
340 | } /* shutdown_socket */ | ||
374 | 341 | ||
375 | The central event handler. Send_event() sends an event to the | ||
376 | 16-bit subsystem, which then calls the relevant device drivers. | ||
377 | Parse_events() interprets the event bits from | ||
378 | a card status change report. Do_shutdown() handles the high | ||
379 | priority stuff associated with a card removal. | ||
380 | |||
381 | ======================================================================*/ | ||
382 | 342 | ||
343 | /** | ||
344 | * The central event handler. Send_event() sends an event to the | ||
345 | * 16-bit subsystem, which then calls the relevant device drivers. | ||
346 | * Parse_events() interprets the event bits from | ||
347 | * a card status change report. Do_shutdown() handles the high | ||
348 | * priority stuff associated with a card removal. | ||
349 | */ | ||
383 | 350 | ||
384 | /* NOTE: send_event needs to be called with skt->sem held. */ | 351 | /* NOTE: send_event needs to be called with skt->sem held. */ |
385 | 352 | ||
@@ -738,27 +705,7 @@ void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) | |||
738 | wake_up(&s->thread_wait); | 705 | wake_up(&s->thread_wait); |
739 | } | 706 | } |
740 | } /* pcmcia_parse_events */ | 707 | } /* pcmcia_parse_events */ |
741 | 708 | EXPORT_SYMBOL(pcmcia_parse_events); | |
742 | |||
743 | /*===================================================================== | ||
744 | |||
745 | Return the PCI device associated with a card.. | ||
746 | |||
747 | ======================================================================*/ | ||
748 | |||
749 | #ifdef CONFIG_CARDBUS | ||
750 | |||
751 | struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s) | ||
752 | { | ||
753 | if (!s || !(s->state & SOCKET_CARDBUS)) | ||
754 | return NULL; | ||
755 | |||
756 | return s->cb_dev->subordinate; | ||
757 | } | ||
758 | |||
759 | EXPORT_SYMBOL(pcmcia_lookup_bus); | ||
760 | |||
761 | #endif | ||
762 | 709 | ||
763 | 710 | ||
764 | /* register pcmcia_callback */ | 711 | /* register pcmcia_callback */ |
@@ -790,18 +737,15 @@ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) | |||
790 | EXPORT_SYMBOL(pccard_register_pcmcia); | 737 | EXPORT_SYMBOL(pccard_register_pcmcia); |
791 | 738 | ||
792 | 739 | ||
793 | /*====================================================================== | 740 | /* I'm not sure which "reset" function this is supposed to use, |
794 | 741 | * but for now, it uses the low-level interface's reset, not the | |
795 | I'm not sure which "reset" function this is supposed to use, | 742 | * CIS register. |
796 | but for now, it uses the low-level interface's reset, not the | 743 | */ |
797 | CIS register. | ||
798 | |||
799 | ======================================================================*/ | ||
800 | 744 | ||
801 | int pccard_reset_card(struct pcmcia_socket *skt) | 745 | int pccard_reset_card(struct pcmcia_socket *skt) |
802 | { | 746 | { |
803 | int ret; | 747 | int ret; |
804 | 748 | ||
805 | cs_dbg(skt, 1, "resetting socket\n"); | 749 | cs_dbg(skt, 1, "resetting socket\n"); |
806 | 750 | ||
807 | down(&skt->skt_sem); | 751 | down(&skt->skt_sem); |
@@ -834,17 +778,14 @@ int pccard_reset_card(struct pcmcia_socket *skt) | |||
834 | } /* reset_card */ | 778 | } /* reset_card */ |
835 | EXPORT_SYMBOL(pccard_reset_card); | 779 | EXPORT_SYMBOL(pccard_reset_card); |
836 | 780 | ||
837 | /*====================================================================== | ||
838 | |||
839 | These shut down or wake up a socket. They are sort of user | ||
840 | initiated versions of the APM suspend and resume actions. | ||
841 | |||
842 | ======================================================================*/ | ||
843 | 781 | ||
782 | /* These shut down or wake up a socket. They are sort of user | ||
783 | * initiated versions of the APM suspend and resume actions. | ||
784 | */ | ||
844 | int pcmcia_suspend_card(struct pcmcia_socket *skt) | 785 | int pcmcia_suspend_card(struct pcmcia_socket *skt) |
845 | { | 786 | { |
846 | int ret; | 787 | int ret; |
847 | 788 | ||
848 | cs_dbg(skt, 1, "suspending socket\n"); | 789 | cs_dbg(skt, 1, "suspending socket\n"); |
849 | 790 | ||
850 | down(&skt->skt_sem); | 791 | down(&skt->skt_sem); |
@@ -863,6 +804,8 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt) | |||
863 | 804 | ||
864 | return ret; | 805 | return ret; |
865 | } /* suspend_card */ | 806 | } /* suspend_card */ |
807 | EXPORT_SYMBOL(pcmcia_suspend_card); | ||
808 | |||
866 | 809 | ||
867 | int pcmcia_resume_card(struct pcmcia_socket *skt) | 810 | int pcmcia_resume_card(struct pcmcia_socket *skt) |
868 | { | 811 | { |
@@ -886,13 +829,10 @@ int pcmcia_resume_card(struct pcmcia_socket *skt) | |||
886 | 829 | ||
887 | return ret; | 830 | return ret; |
888 | } /* resume_card */ | 831 | } /* resume_card */ |
832 | EXPORT_SYMBOL(pcmcia_resume_card); | ||
889 | 833 | ||
890 | /*====================================================================== | ||
891 | |||
892 | These handle user requests to eject or insert a card. | ||
893 | |||
894 | ======================================================================*/ | ||
895 | 834 | ||
835 | /* These handle user requests to eject or insert a card. */ | ||
896 | int pcmcia_eject_card(struct pcmcia_socket *skt) | 836 | int pcmcia_eject_card(struct pcmcia_socket *skt) |
897 | { | 837 | { |
898 | int ret; | 838 | int ret; |
@@ -919,6 +859,8 @@ int pcmcia_eject_card(struct pcmcia_socket *skt) | |||
919 | 859 | ||
920 | return ret; | 860 | return ret; |
921 | } /* eject_card */ | 861 | } /* eject_card */ |
862 | EXPORT_SYMBOL(pcmcia_eject_card); | ||
863 | |||
922 | 864 | ||
923 | int pcmcia_insert_card(struct pcmcia_socket *skt) | 865 | int pcmcia_insert_card(struct pcmcia_socket *skt) |
924 | { | 866 | { |
@@ -942,6 +884,8 @@ int pcmcia_insert_card(struct pcmcia_socket *skt) | |||
942 | 884 | ||
943 | return ret; | 885 | return ret; |
944 | } /* insert_card */ | 886 | } /* insert_card */ |
887 | EXPORT_SYMBOL(pcmcia_insert_card); | ||
888 | |||
945 | 889 | ||
946 | static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, | 890 | static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, |
947 | int num_envp, char *buffer, int buffer_size) | 891 | int num_envp, char *buffer, int buffer_size) |
@@ -958,20 +902,6 @@ static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, | |||
958 | return 0; | 902 | return 0; |
959 | } | 903 | } |
960 | 904 | ||
961 | /*====================================================================== | ||
962 | |||
963 | OS-specific module glue goes here | ||
964 | |||
965 | ======================================================================*/ | ||
966 | /* in alpha order */ | ||
967 | EXPORT_SYMBOL(pcmcia_eject_card); | ||
968 | EXPORT_SYMBOL(pcmcia_insert_card); | ||
969 | EXPORT_SYMBOL(pcmcia_replace_cis); | ||
970 | EXPORT_SYMBOL(pcmcia_resume_card); | ||
971 | EXPORT_SYMBOL(pcmcia_suspend_card); | ||
972 | |||
973 | EXPORT_SYMBOL(dead_socket); | ||
974 | EXPORT_SYMBOL(pcmcia_parse_events); | ||
975 | 905 | ||
976 | struct class pcmcia_socket_class = { | 906 | struct class pcmcia_socket_class = { |
977 | .name = "pcmcia_socket", | 907 | .name = "pcmcia_socket", |
@@ -983,11 +913,7 @@ EXPORT_SYMBOL(pcmcia_socket_class); | |||
983 | 913 | ||
984 | static int __init init_pcmcia_cs(void) | 914 | static int __init init_pcmcia_cs(void) |
985 | { | 915 | { |
986 | int ret; | 916 | int ret = class_register(&pcmcia_socket_class); |
987 | printk(KERN_INFO "%s\n", release); | ||
988 | printk(KERN_INFO " %s\n", options); | ||
989 | |||
990 | ret = class_register(&pcmcia_socket_class); | ||
991 | if (ret) | 917 | if (ret) |
992 | return (ret); | 918 | return (ret); |
993 | return class_interface_register(&pccard_sysfs_interface); | 919 | return class_interface_register(&pccard_sysfs_interface); |
@@ -995,13 +921,10 @@ static int __init init_pcmcia_cs(void) | |||
995 | 921 | ||
996 | static void __exit exit_pcmcia_cs(void) | 922 | static void __exit exit_pcmcia_cs(void) |
997 | { | 923 | { |
998 | printk(KERN_INFO "unloading Kernel Card Services\n"); | 924 | class_interface_unregister(&pccard_sysfs_interface); |
999 | class_interface_unregister(&pccard_sysfs_interface); | 925 | class_unregister(&pcmcia_socket_class); |
1000 | class_unregister(&pcmcia_socket_class); | ||
1001 | } | 926 | } |
1002 | 927 | ||
1003 | subsys_initcall(init_pcmcia_cs); | 928 | subsys_initcall(init_pcmcia_cs); |
1004 | module_exit(exit_pcmcia_cs); | 929 | module_exit(exit_pcmcia_cs); |
1005 | 930 | ||
1006 | /*====================================================================*/ | ||
1007 | |||
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 7aa2e7f20d50..fa2a79d29e16 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -275,8 +275,16 @@ rescan: | |||
275 | return (ret); | 275 | return (ret); |
276 | } /* bind_request */ | 276 | } /* bind_request */ |
277 | 277 | ||
278 | #ifdef CONFIG_CARDBUS | ||
279 | |||
280 | static struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s) | ||
281 | { | ||
282 | if (!s || !(s->state & SOCKET_CARDBUS)) | ||
283 | return NULL; | ||
278 | 284 | ||
279 | extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s); | 285 | return s->cb_dev->subordinate; |
286 | } | ||
287 | #endif | ||
280 | 288 | ||
281 | static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int first) | 289 | static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int first) |
282 | { | 290 | { |