static int parportfd = -1;
-int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, int ecpbase, int num) {
+int parport_transfer(WD_TRANSFER *tr, int fd, unsigned int request, int ppbase, int ecpbase, int num) {
int ret = 0;
int i;
unsigned long port;
unsigned char val;
static unsigned char last_pp_write = 0;
+ if (parportfd < 0)
+ return ret;
+
+ if (ioctl(parportfd, PPCLAIM) == -1)
+ return -1;
+
for (i = 0; i < num; i++) {
DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n",
(unsigned long)tr[i].dwPort, tr[i].cmdTrans, tr[i].dwBytes,
DPRINTF("write byte: %d\n", val);
#endif
- if (parportfd < 0)
- return ret;
-
if (port == ppbase + PP_DATA) {
DPRINTF("data port\n");
switch(tr[i].cmdTrans) {
#endif
}
+ ioctl(parportfd, PPRELEASE);
+
return ret;
}
if (ioctl(parportfd, PPNEGOT, &pmode) == -1)
return -1;
+ ioctl(parportfd, PPRELEASE);
#if 0
if (cr->Card.dwItems > 1 && cr->Card.Item[1].I.IO.dwAddr) {
DPRINTF("ECP mode requested\n");