[PATCH] pcmcia: cs.c cleanup

Clean up cs.c

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Dominik Brodowski and committed by Linus Torvalds 33519ddd 1a8d4663

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