replace some function names
[linux-2.6/zen-sources.git] / arch / sparc / prom / devops.c
blob9f1a95c91ad12f3b7742c381d9a0b864f79e97bb
1 /*
2 * devops.c: Device operations using the PROM.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
5 */
6 #include <linux/types.h>
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
10 #include <asm/openprom.h>
11 #include <asm/oplib.h>
13 extern void restore_current(void);
15 /* Open the device described by the string 'dstr'. Returns the handle
16 * to that device used for subsequent operations on that device.
17 * Returns -1 on failure.
19 int
20 prom_devopen(char *dstr)
22 int handle;
23 unsigned long flags;
24 spin_lock_irqsave(&prom_lock, flags);
25 switch(prom_vers) {
26 case PROM_V0:
27 handle = (*(romvec->pv_v0devops.v0_devopen))(dstr);
28 if(handle == 0) handle = -1;
29 break;
30 case PROM_V2:
31 case PROM_V3:
32 handle = (*(romvec->pv_v2devops.v2_dev_open))(dstr);
33 break;
34 default:
35 handle = -1;
36 break;
38 restore_current();
39 spin_unlock_irqrestore(&prom_lock, flags);
41 return handle;
44 /* Close the device described by device handle 'dhandle'. */
45 int
46 prom_devclose(int dhandle)
48 unsigned long flags;
49 spin_lock_irqsave(&prom_lock, flags);
50 switch(prom_vers) {
51 case PROM_V0:
52 (*(romvec->pv_v0devops.v0_devclose))(dhandle);
53 break;
54 case PROM_V2:
55 case PROM_V3:
56 (*(romvec->pv_v2devops.v2_dev_close))(dhandle);
57 break;
58 default:
59 break;
61 restore_current();
62 spin_unlock_irqrestore(&prom_lock, flags);
63 return 0;
66 /* Seek to specified location described by 'seekhi' and 'seeklo'
67 * for device 'dhandle'.
69 void
70 prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
72 unsigned long flags;
73 spin_lock_irqsave(&prom_lock, flags);
74 switch(prom_vers) {
75 case PROM_V0:
76 (*(romvec->pv_v0devops.v0_seekdev))(dhandle, seekhi, seeklo);
77 break;
78 case PROM_V2:
79 case PROM_V3:
80 (*(romvec->pv_v2devops.v2_dev_seek))(dhandle, seekhi, seeklo);
81 break;
82 default:
83 break;
85 restore_current();
86 spin_unlock_irqrestore(&prom_lock, flags);
88 return;