1 /* $Id: devops.c,v 1.13 2000/08/26 02:38:03 anton Exp $
2 * devops.c: Device operations using the PROM.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
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.
20 prom_devopen(char *dstr
)
24 spin_lock_irqsave(&prom_lock
, flags
);
27 handle
= (*(romvec
->pv_v0devops
.v0_devopen
))(dstr
);
28 if(handle
== 0) handle
= -1;
32 handle
= (*(romvec
->pv_v2devops
.v2_dev_open
))(dstr
);
39 spin_unlock_irqrestore(&prom_lock
, flags
);
44 /* Close the device described by device handle 'dhandle'. */
46 prom_devclose(int dhandle
)
49 spin_lock_irqsave(&prom_lock
, flags
);
52 (*(romvec
->pv_v0devops
.v0_devclose
))(dhandle
);
56 (*(romvec
->pv_v2devops
.v2_dev_close
))(dhandle
);
62 spin_unlock_irqrestore(&prom_lock
, flags
);
66 /* Seek to specified location described by 'seekhi' and 'seeklo'
67 * for device 'dhandle'.
70 prom_seek(int dhandle
, unsigned int seekhi
, unsigned int seeklo
)
73 spin_lock_irqsave(&prom_lock
, flags
);
76 (*(romvec
->pv_v0devops
.v0_seekdev
))(dhandle
, seekhi
, seeklo
);
80 (*(romvec
->pv_v2devops
.v2_dev_seek
))(dhandle
, seekhi
, seeklo
);
86 spin_unlock_irqrestore(&prom_lock
, flags
);