aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/srcpos.c
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2009-10-15 15:13:36 -0400
committerJosh Triplett <josh@joshtriplett.org>2009-11-15 18:00:16 -0500
commit65166571800af0f63f21e5576d7db12d2bf73790 (patch)
tree42bae137b3966ff60c28619cd22c84cf20ec1c79 /scripts/dtc/srcpos.c
parent1456edbb1476db735715ddcc7ac306de587024eb (diff)
kconfig: Mark various internal functions static
kconfig's keyword hash, lexer, and parser define various functions used only locally. Declare these functions as static, and regenerate the corresponding generated files. Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'scripts/dtc/srcpos.c')
0 files changed, 0 insertions, 0 deletions
lass='alt'>
33519ddd43f4
1da177e4c3f4















1da177e4c3f4



33519ddd43f4
1da177e4c3f4



1da177e4c3f4
1da177e4c3f4
33519ddd43f4

1da177e4c3f4
1da177e4c3f4
9fea84f46a82
1da177e4c3f4
873733188a01

1da177e4c3f4
593f010bc0d8
1da177e4c3f4





873733188a01
1da177e4c3f4



873733188a01
1da177e4c3f4
873733188a01
1da177e4c3f4







78187865efa5
1da177e4c3f4


1da9ab7389b8
1da177e4c3f4

873733188a01
1da177e4c3f4

d50dbec3ce52
1da177e4c3f4
1da177e4c3f4
33519ddd43f4

1da177e4c3f4



















5bc6b68a103a






1da177e4c3f4

873733188a01
1da177e4c3f4
2509698687e2
1da177e4c3f4








7fe908dd11e0
6b8e087b86c5
1da177e4c3f4

b1769450da0e
cfe5d809518e
b1769450da0e
cfe5d809518e
b1769450da0e



1da9ab7389b8


1da177e4c3f4
1da9ab7389b8
1da177e4c3f4

1da9ab7389b8
2e55bf6b99fb

1da177e4c3f4

1da9ab7389b8
1da177e4c3f4

638bba55fe64






1da177e4c3f4












78187865efa5
1da177e4c3f4





d50dbec3ce52
1da177e4c3f4
0b4020941997
1da9ab7389b8
0b4020941997
1da177e4c3f4





cfe5d809518e

385ee871092a
cfe5d809518e

1da177e4c3f4




9fea84f46a82
1da177e4c3f4















1da177e4c3f4



d50dbec3ce52
1da177e4c3f4












3939c1ef1f95
1da177e4c3f4

4c89e88bfde6
1da177e4c3f4



d50dbec3ce52
8567142e8732
1da177e4c3f4

78187865efa5
6e493882726e








d50dbec3ce52
6e493882726e
7b24e7988263

9e86749cff70

6e493882726e







6e493882726e
904e377744bf

c3bfc96ef736









6e493882726e


6e493882726e
afb2c1650b4c


6e493882726e

2e55bf6b99fb

6e493882726e

3970dd8c5169
6e493882726e

1da177e4c3f4



d50dbec3ce52
1da177e4c3f4


3939c1ef1f95
1da177e4c3f4





3939c1ef1f95
1da177e4c3f4







d50dbec3ce52

8567142e8732
1da177e4c3f4


5bc6b68a103a
d50dbec3ce52

610e23749e87
5bc6b68a103a
1da177e4c3f4
88b060d6c03f

1da177e4c3f4








d50dbec3ce52
610e23749e87
1da177e4c3f4
fa912bcb06d5



1da177e4c3f4









d50dbec3ce52
610e23749e87
1da177e4c3f4

fa912bcb06d5





1da177e4c3f4









d50dbec3ce52
1da177e4c3f4
9e86749cff70
f971dbd5da4e



3970dd8c5169
1da177e4c3f4

4c89e88bfde6
1da177e4c3f4
807277cbf9a2
2e55bf6b99fb



807277cbf9a2
1da177e4c3f4





d50dbec3ce52
9e86749cff70
1da177e4c3f4
7b24e7988263

1da177e4c3f4
9e86749cff70
1da177e4c3f4
1da177e4c3f4







f958095ef4fc
1da177e4c3f4
9e86749cff70
88b060d6c03f

1da177e4c3f4




9e86749cff70
4c89e88bfde6
1da177e4c3f4

9905d1b41194
1da177e4c3f4
9e86749cff70
1da177e4c3f4


9905d1b41194

9e86749cff70
9905d1b41194

1da177e4c3f4
9905d1b41194

d7646f763254

9e86749cff70
88b060d6c03f
9e86749cff70
88b060d6c03f
d7646f763254





88b060d6c03f



1da177e4c3f4

88b060d6c03f




1da177e4c3f4
88b060d6c03f
1da177e4c3f4

88b060d6c03f









7b24e7988263

4c89e88bfde6
1da177e4c3f4

9905d1b41194













1da177e4c3f4

2e55bf6b99fb

1da177e4c3f4
1da177e4c3f4

































1da177e4c3f4

1da177e4c3f4





873733188a01
1da177e4c3f4
2e55bf6b99fb

1da177e4c3f4
1da9ab7389b8

1da177e4c3f4
4356d73d028a


1da177e4c3f4
bf4de6f2db79

d801c1409ef7


831441862956
1da177e4c3f4


f971dbd5da4e
1da177e4c3f4





f971dbd5da4e

1da177e4c3f4

f971dbd5da4e
216d7cdd3b06

1da177e4c3f4
f971dbd5da4e




f971dbd5da4e





43821242078a
f971dbd5da4e
43821242078a







f971dbd5da4e
af461fc1875b




f971dbd5da4e





1da9ab7389b8
1da177e4c3f4
bf4de6f2db79


1da177e4c3f4
220ec0291130


3970dd8c5169






1da177e4c3f4
4356d73d028a
873733188a01
1da177e4c3f4
1da9ab7389b8
1da177e4c3f4







4b7a89a3c1cf
d50dbec3ce52
1da177e4c3f4
4b7a89a3c1cf
1da177e4c3f4
4b7a89a3c1cf
1da177e4c3f4
0b4020941997
1da177e4c3f4

33519ddd43f4
1da177e4c3f4
f971dbd5da4e







af461fc1875b

f971dbd5da4e














1da177e4c3f4



9fea84f46a82
1da177e4c3f4
7fe908dd11e0

1da177e4c3f4










7b24e7988263
1da177e4c3f4


7fe908dd11e0
1da177e4c3f4




1da177e4c3f4
33519ddd43f4



1da177e4c3f4
994917f8b718
1da177e4c3f4

33519ddd43f4
d50dbec3ce52
1da177e4c3f4
7fe908dd11e0
1da177e4c3f4

6d9a299f675b
3939c1ef1f95
1da177e4c3f4


6d9a299f675b
f958095ef4fc
1da177e4c3f4


6d9a299f675b
de6405e9d1e7
1da177e4c3f4


216d7cdd3b06






1da177e4c3f4
4c89e88bfde6
1da177e4c3f4
7fe908dd11e0
1da177e4c3f4


994917f8b718
1da177e4c3f4
1da177e4c3f4
7eff2e7a8b65

3ee13937525f

3ee13937525f
7eff2e7a8b65
3ee13937525f

3ee13937525f


1da177e4c3f4
378a33a686d4







d7646f763254
























3c7d2b765df9
d7646f763254



























1da177e4c3f4

873733188a01

378a33a686d4
d7646f763254
1da177e4c3f4





378a33a686d4
4356d73d028a
1da177e4c3f4



33519ddd43f4
378a33a686d4
1da177e4c3f4




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900

















                                                                       









                            
                         
                          
                          


                       
                      




                          



                                                             
                                                 















                                                                          



                                    
                           



                                               
                                  
 

                                        
 
 
                                                                  
 

                                                   
                            
                                    





                                                 
                              



                                 
                                                     
 
                                                            







                                                          
                                   


                                                        
                                

                
                                                                                    

                               
                                                                             
 
                                                                 

                                                           



















                                                                                    






                                                     

                                              
                                              
                                                 
                                                                    








                                                  
                                       
                                       

                                             
                                         
                                               
                                                         
                                                 



                                 


                                                      
                         
         

                                                  
                              

                                                                             

                            
 

                                               






                                                                         












                                                           
                                     





                                                           
                                                                               
 
                           
                                             
 





                                                   

                                               
                                                   

                                                 




                                                      
                                                              















                                                                



                                                  
                                      












                                                      
                                       

                                      
                                 



                                           
                                                                   
                          

 
  








                                                                             
                                       
 

                                       

                                  







                                                  
                          

                           









                                                                 


                     
 


                                                 

                                       

                                                                             

         
                                  

 



                                                                     
                                      


                                           
                               





                                                   
                                       







                                           

                                                                 
                                  


                                  
                                                        

                                                                      
                                       
                 
                                             

                                              








                                                                             
                                                                              
                            
         



                                                     









                                                         
                                                                            
                            

         





                                                      









                                                            
                                       
 
                                    



                                              
                                   

                                             
                       
                                             
 



                                                                                
 





                                                            
                                                    
                                              
 

                                                                      
                
                                              
                                     







                                                    
                              
 
                                    

                                          




                                                
                                      
                 

 
                                                         
 
                                    


                                                

                                                                     
                                      

                 
 

                                                        

                
                                    
                                      
                                      
 





                                             



                                     

         




                                                                    
                                     
                                          

         









                                                                    

                                                              
                 

 













                                                                 

                                                    

                                                                     
                             

































                                                                        

                





                                                
                                         
                  

                                                                  
                                   

                                            
         


                                                                              
 

                                    


                                            
                        


                                    
                                          





                                                            

                                                 

                                                                 
                                            

                                                  
 




                                                                





                                                                          
                                           
                                                            







                                                                    
                         




                                                                     





                                              
                                          
                              


                                
         


                                                     






                                                            
                                         
                                              
                                     
 
                 







                                                                       
                            
                                                                
                        
                                                          
                                           
                                                               
 
                                           

                           
                                   
 







                                                                           

                                                                         














                                                                 



                                                                              
                    
 

                                                    










                                                                                   
                                            


                                   
                                    




                                      
 



                                                                
 
                                                

                
 
                                                 
 
                                    

                                                     
                                                                         
                                      


                                                  
                                                                       
                                     


                                                  
                                                                        
                                     


                              






                                                    
 
                        
                    
                                      


                   
                                 
 
 

                                                            

                                                                               
 
                                                         

                               


                 
 







                                                           
























                                                                               
                                                              



























                                                            

                                    

                                             
                                                     
                                         





                                      
                                        
                                                    



                                       
                                               
                                            




                                
/*
 * cs.c -- Kernel Card Services - core services
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * The initial developer of the original code is David A. Hinds
 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 *
 * (C) 1999		David A. Hinds
 */

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/major.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/ioport.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/device.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <asm/system.h>
#include <asm/irq.h>

#include <pcmcia/ss.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/ds.h>
#include "cs_internal.h"


/* Module parameters */

MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("Linux Kernel Card Services");
MODULE_LICENSE("GPL");

#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444)

INT_MODULE_PARM(setup_delay,	10);		/* centiseconds */
INT_MODULE_PARM(resume_delay,	20);		/* centiseconds */
INT_MODULE_PARM(shutdown_delay,	3);		/* centiseconds */
INT_MODULE_PARM(vcc_settle,	40);		/* centiseconds */
INT_MODULE_PARM(reset_time,	10);		/* usecs */
INT_MODULE_PARM(unreset_delay,	10);		/* centiseconds */
INT_MODULE_PARM(unreset_check,	10);		/* centiseconds */
INT_MODULE_PARM(unreset_limit,	30);		/* unreset_check's */

/* Access speed for attribute memory windows */
INT_MODULE_PARM(cis_speed,	300);		/* ns */


socket_state_t dead_socket = {
	.csc_mask	= SS_DETECT,
};
EXPORT_SYMBOL(dead_socket);


/* List of all sockets, protected by a rwsem */
LIST_HEAD(pcmcia_socket_list);
EXPORT_SYMBOL(pcmcia_socket_list);

DECLARE_RWSEM(pcmcia_socket_list_rwsem);
EXPORT_SYMBOL(pcmcia_socket_list_rwsem);


struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt)
{
	struct device *dev = get_device(&skt->dev);
	if (!dev)
		return NULL;
	return dev_get_drvdata(dev);
}
EXPORT_SYMBOL(pcmcia_get_socket);


void pcmcia_put_socket(struct pcmcia_socket *skt)
{
	put_device(&skt->dev);
}
EXPORT_SYMBOL(pcmcia_put_socket);


static void pcmcia_release_socket(struct device *dev)
{
	struct pcmcia_socket *socket = dev_get_drvdata(dev);

	complete(&socket->socket_released);
}

static int pccardd(void *__skt);

/**
 * pcmcia_register_socket - add a new pcmcia socket device
 * @socket: the &socket to register
 */
int pcmcia_register_socket(struct pcmcia_socket *socket)
{
	struct task_struct *tsk;
	int ret;

	if (!socket || !socket->ops || !socket->dev.parent || !socket->resource_ops)
		return -EINVAL;

	dev_dbg(&socket->dev, "pcmcia_register_socket(0x%p)\n", socket->ops);

	/* try to obtain a socket number [yes, it gets ugly if we
	 * register more than 2^sizeof(unsigned int) pcmcia
	 * sockets... but the socket number is deprecated
	 * anyways, so I don't care] */
	down_write(&pcmcia_socket_list_rwsem);
	if (list_empty(&pcmcia_socket_list))
		socket->sock = 0;
	else {
		unsigned int found, i = 1;
		struct pcmcia_socket *tmp;
		do {
			found = 1;
			list_for_each_entry(tmp, &pcmcia_socket_list, socket_list) {
				if (tmp->sock == i)
					found = 0;
			}
			i++;
		} while (!found);
		socket->sock = i - 1;
	}
	list_add_tail(&socket->socket_list, &pcmcia_socket_list);
	up_write(&pcmcia_socket_list_rwsem);

#ifndef CONFIG_CARDBUS
	/*
	 * If we do not support Cardbus, ensure that
	 * the Cardbus socket capability is disabled.
	 */
	socket->features &= ~SS_CAP_CARDBUS;
#endif

	/* set proper values in socket->dev */
	dev_set_drvdata(&socket->dev, socket);
	socket->dev.class = &pcmcia_socket_class;
	dev_set_name(&socket->dev, "pcmcia_socket%u", socket->sock);

	/* base address = 0, map = 0 */
	socket->cis_mem.flags = 0;
	socket->cis_mem.speed = cis_speed;

	INIT_LIST_HEAD(&socket->cis_cache);

	init_completion(&socket->socket_released);
	init_completion(&socket->thread_done);
	mutex_init(&socket->skt_mutex);
	mutex_init(&socket->ops_mutex);
	spin_lock_init(&socket->thread_lock);

	if (socket->resource_ops->init) {
		mutex_lock(&socket->ops_mutex);
		ret = socket->resource_ops->init(socket);
		mutex_unlock(&socket->ops_mutex);
		if (ret)
			goto err;
	}

	tsk = kthread_run(pccardd, socket, "pccardd");
	if (IS_ERR(tsk)) {
		ret = PTR_ERR(tsk);
		goto err;
	}

	wait_for_completion(&socket->thread_done);
	if (!socket->thread) {
		dev_printk(KERN_WARNING, &socket->dev,
			   "PCMCIA: warning: socket thread did not start\n");
		return -EIO;
	}

	pcmcia_parse_events(socket, SS_DETECT);

	/*
	 * Let's try to get the PCMCIA module for 16-bit PCMCIA support.
	 * If it fails, it doesn't matter -- we still have 32-bit CardBus
	 * support to offer, so this is not a failure mode.
	 */
	request_module_nowait("pcmcia");

	return 0;

 err:
	down_write(&pcmcia_socket_list_rwsem);
	list_del(&socket->socket_list);
	up_write(&pcmcia_socket_list_rwsem);
	return ret;
} /* pcmcia_register_socket */
EXPORT_SYMBOL(pcmcia_register_socket);


/**
 * pcmcia_unregister_socket - remove a pcmcia socket device
 * @socket: the &socket to unregister
 */
void pcmcia_unregister_socket(struct pcmcia_socket *socket)
{
	if (!socket)
		return;

	dev_dbg(&socket->dev, "pcmcia_unregister_socket(0x%p)\n", socket->ops);

	if (socket->thread)
		kthread_stop(socket->thread);

	/* remove from our own list */
	down_write(&pcmcia_socket_list_rwsem);
	list_del(&socket->socket_list);
	up_write(&pcmcia_socket_list_rwsem);

	/* wait for sysfs to drop all references */
	if (socket->resource_ops->exit) {
		mutex_lock(&socket->ops_mutex);
		socket->resource_ops->exit(socket);
		mutex_unlock(&socket->ops_mutex);
	}
	wait_for_completion(&socket->socket_released);
} /* pcmcia_unregister_socket */
EXPORT_SYMBOL(pcmcia_unregister_socket);


struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr)
{
	struct pcmcia_socket *s;

	down_read(&pcmcia_socket_list_rwsem);
	list_for_each_entry(s, &pcmcia_socket_list, socket_list)
		if (s->sock == nr) {
			up_read(&pcmcia_socket_list_rwsem);
			return s;
		}
	up_read(&pcmcia_socket_list_rwsem);

	return NULL;

}
EXPORT_SYMBOL(pcmcia_get_socket_by_nr);

static int socket_reset(struct pcmcia_socket *skt)
{
	int status, i;

	dev_dbg(&skt->dev, "reset\n");

	skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET;
	skt->ops->set_socket(skt, &skt->socket);
	udelay((long)reset_time);

	skt->socket.flags &= ~SS_RESET;
	skt->ops->set_socket(skt, &skt->socket);

	msleep(unreset_delay * 10);
	for (i = 0; i < unreset_limit; i++) {
		skt->ops->get_status(skt, &status);

		if (!(status & SS_DETECT))
			return -ENODEV;

		if (status & SS_READY)
			return 0;

		msleep(unreset_check * 10);
	}

	dev_printk(KERN_ERR, &skt->dev, "time out after reset.\n");
	return -ETIMEDOUT;
}

/*
 * socket_setup() and socket_shutdown() are called by the main event handler
 * when card insertion and removal events are received.
 * socket_setup() turns on socket power and resets the socket, in two stages.
 * socket_shutdown() unconfigures a socket and turns off socket power.
 */
static void socket_shutdown(struct pcmcia_socket *s)
{
	int status;

	dev_dbg(&s->dev, "shutdown\n");

	if (s->callback)
		s->callback->remove(s);

	mutex_lock(&s->ops_mutex);
	s->state &= SOCKET_INUSE | SOCKET_PRESENT;
	msleep(shutdown_delay * 10);
	s->state &= SOCKET_INUSE;

	/* Blank out the socket state */
	s->socket = dead_socket;
	s->ops->init(s);
	s->ops->set_socket(s, &s->socket);
	s->lock_count = 0;
	kfree(s->fake_cis);
	s->fake_cis = NULL;
	s->functions = 0;

	/* From here on we can be sure that only we (that is, the
	 * pccardd thread) accesses this socket, and all (16-bit)
	 * PCMCIA interactions are gone. Therefore, release
	 * ops_mutex so that we don't get a sysfs-related lockdep
	 * warning.
	 */
	mutex_unlock(&s->ops_mutex);

#ifdef CONFIG_CARDBUS
	cb_free(s);
#endif

	/* give socket some time to power down */
	msleep(100);

	s->ops->get_status(s, &status);
	if (status & SS_POWERON) {
		dev_printk(KERN_ERR, &s->dev,
			   "*** DANGER *** unable to remove socket power\n");
	}

	s->state &= ~SOCKET_INUSE;
}

static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
{
	int status, i;

	dev_dbg(&skt->dev, "setup\n");

	skt->ops->get_status(skt, &status);
	if (!(status & SS_DETECT))
		return -ENODEV;

	msleep(initial_delay * 10);

	for (i = 0; i < 100; i++) {
		skt->ops->get_status(skt, &status);
		if (!(status & SS_DETECT))
			return -ENODEV;

		if (!(status & SS_PENDING))
			break;

		msleep(100);
	}

	if (status & SS_PENDING) {
		dev_printk(KERN_ERR, &skt->dev,
			   "voltage interrogation timed out.\n");
		return -ETIMEDOUT;
	}

	if (status & SS_CARDBUS) {
		if (!(skt->features & SS_CAP_CARDBUS)) {
			dev_printk(KERN_ERR, &skt->dev,
				"cardbus cards are not supported.\n");
			return -EINVAL;
		}
		skt->state |= SOCKET_CARDBUS;
	} else
		skt->state &= ~SOCKET_CARDBUS;

	/*
	 * Decode the card voltage requirements, and apply power to the card.
	 */
	if (status & SS_3VCARD)
		skt->socket.Vcc = skt->socket.Vpp = 33;
	else if (!(status & SS_XVCARD))
		skt->socket.Vcc = skt->socket.Vpp = 50;
	else {
		dev_printk(KERN_ERR, &skt->dev, "unsupported voltage key.\n");
		return -EIO;
	}

	if (skt->power_hook)
		skt->power_hook(skt, HOOK_POWER_PRE);

	skt->socket.flags = 0;
	skt->ops->set_socket(skt, &skt->socket);

	/*
	 * Wait "vcc_settle" for the supply to stabilise.
	 */
	msleep(vcc_settle * 10);

	skt->ops->get_status(skt, &status);
	if (!(status & SS_POWERON)) {
		dev_printk(KERN_ERR, &skt->dev, "unable to apply power.\n");
		return -EIO;
	}

	status = socket_reset(skt);

	if (skt->power_hook)
		skt->power_hook(skt, HOOK_POWER_POST);

	return status;
}

/*
 * Handle card insertion.  Setup the socket, reset the card,
 * and then tell the rest of PCMCIA that a card is present.
 */
static int socket_insert(struct pcmcia_socket *skt)
{
	int ret;

	dev_dbg(&skt->dev, "insert\n");

	mutex_lock(&skt->ops_mutex);
	if (skt->state & SOCKET_INUSE) {
		mutex_unlock(&skt->ops_mutex);
		return -EINVAL;
	}
	skt->state |= SOCKET_INUSE;

	ret = socket_setup(skt, setup_delay);
	if (ret == 0) {
		skt->state |= SOCKET_PRESENT;

		dev_printk(KERN_NOTICE, &skt->dev,
			   "pccard: %s card inserted into slot %d\n",
			   (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
			   skt->sock);

#ifdef CONFIG_CARDBUS
		if (skt->state & SOCKET_CARDBUS) {
			cb_alloc(skt);
			skt->state |= SOCKET_CARDBUS_CONFIG;
		}
#endif
		dev_dbg(&skt->dev, "insert done\n");
		mutex_unlock(&skt->ops_mutex);

		if (!(skt->state & SOCKET_CARDBUS) && (skt->callback))
			skt->callback->add(skt);
	} else {
		mutex_unlock(&skt->ops_mutex);
		socket_shutdown(skt);
	}

	return ret;
}

static int socket_suspend(struct pcmcia_socket *skt)
{
	if (skt->state & SOCKET_SUSPEND)
		return -EBUSY;

	mutex_lock(&skt->ops_mutex);
	skt->suspended_state = skt->state;

	skt->socket = dead_socket;
	skt->ops->set_socket(skt, &skt->socket);
	if (skt->ops->suspend)
		skt->ops->suspend(skt);
	skt->state |= SOCKET_SUSPEND;
	mutex_unlock(&skt->ops_mutex);
	return 0;
}

static int socket_early_resume(struct pcmcia_socket *skt)
{
	mutex_lock(&skt->ops_mutex);
	skt->socket = dead_socket;
	skt->ops->init(skt);
	skt->ops->set_socket(skt, &skt->socket);
	if (skt->state & SOCKET_PRESENT)
		skt->resume_status = socket_setup(skt, resume_delay);
	mutex_unlock(&skt->ops_mutex);
	return 0;
}

static int socket_late_resume(struct pcmcia_socket *skt)
{
	int ret;

	mutex_lock(&skt->ops_mutex);
	skt->state &= ~SOCKET_SUSPEND;
	mutex_unlock(&skt->ops_mutex);

	if (!(skt->state & SOCKET_PRESENT)) {
		ret = socket_insert(skt);
		if (ret == -ENODEV)
			ret = 0;
		return ret;
	}

	if (skt->resume_status) {
		socket_shutdown(skt);
		return 0;
	}

	if (skt->suspended_state != skt->state) {
		dev_dbg(&skt->dev,
			"suspend state 0x%x != resume state 0x%x\n",
			skt->suspended_state, skt->state);

		socket_shutdown(skt);
		return socket_insert(skt);
	}

#ifdef CONFIG_CARDBUS
	if (skt->state & SOCKET_CARDBUS) {
		/* We can't be sure the CardBus card is the same
		 * as the one previously inserted. Therefore, remove
		 * and re-add... */
		cb_free(skt);
		cb_alloc(skt);
		return 0;
	}
#endif
	if (!(skt->state & SOCKET_CARDBUS) && (skt->callback))
		skt->callback->early_resume(skt);
	return 0;
}

/*
 * Resume a socket.  If a card is present, verify its CIS against
 * our cached copy.  If they are different, the card has been
 * replaced, and we need to tell the drivers.
 */
static int socket_resume(struct pcmcia_socket *skt)
{
	if (!(skt->state & SOCKET_SUSPEND))
		return -EBUSY;