2003-02-11 Theodore A. Roth * linux_ppdev.h: New file. * ppi.c: Include system dependant parallel port interface file. (ppi_open): Add call to ppi_claim(). (ppi_close): Add call to ppi_release(). * ppi.h: Define ppi_claim() and ppi_release() as NOPs if not previously defined. * stk500.c: Include stdlib and inttypes headers. Index: linux_ppdev.h =================================================================== RCS file: linux_ppdev.h diff -N linux_ppdev.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ linux_ppdev.h 11 Feb 2003 21:08:22 -0000 @@ -0,0 +1,37 @@ +#ifndef __linux_ppdev_h__ +#define __linux_ppdev_h__ + +#define OBSOLETE__IOW _IOW + +#include +#include +#include + +#include + +#define PPISDATA PPWDATA +#define PPIGDATA PPRDATA + +#define PPISCTRL PPWCONTROL +#define PPIGCTRL PPRCONTROL + +#define PPISSTATUS PPWSTATUS +#define PPIGSTATUS PPRSTATUS + +#define ppi_claim(pgm) \ + if (ioctl(pgm->fd, PPCLAIM)) { \ + fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \ + progname, port, strerror(errno)); \ + close(pgm->fd); \ + exit(1); \ + } + +#define ppi_release(pgm) \ + if (ioctl(pgm->fd, PPRELEASE)) { \ + fprintf(stderr, "%s: can't release device: %s\n\n", \ + progname, strerror(errno)); \ + exit(1); \ + } + + +#endif /* __linux_ppdev_h__ */ Index: ppi.c =================================================================== RCS file: /cvsroot/avrdude/avrdude/ppi.c,v retrieving revision 1.16 diff -u -r1.16 ppi.c --- ppi.c 9 Feb 2003 13:36:48 -0000 1.16 +++ ppi.c 11 Feb 2003 21:08:22 -0000 @@ -24,7 +24,12 @@ #include #include #include + +#if defined(__FreeBSD__) #include +#elif defined(__linux__) +#include "linux_ppdev.h" +#endif #include "avr.h" #include "pindefs.h" @@ -759,11 +764,15 @@ progname, port, strerror(errno)); exit(1); } + + ppi_claim(pgm); } void ppi_close(PROGRAMMER * pgm) { + ppi_release(pgm); + close(pgm->fd); pgm->fd = -1; } Index: ppi.h =================================================================== RCS file: /cvsroot/avrdude/avrdude/ppi.h,v retrieving revision 1.11 diff -u -r1.11 ppi.h --- ppi.h 9 Feb 2003 13:36:48 -0000 1.11 +++ ppi.h 11 Feb 2003 21:08:22 -0000 @@ -29,7 +29,13 @@ int ppi_getpinmask(int pin); +#if !defined(ppi_claim) +# define ppi_claim(pgm) +#endif +#if !defined(ppi_release) +# define ppi_release(pgm) +#endif #endif Index: stk500.c =================================================================== RCS file: /cvsroot/avrdude/avrdude/stk500.c,v retrieving revision 1.12 diff -u -r1.12 stk500.c --- stk500.c 9 Feb 2003 13:36:48 -0000 1.12 +++ stk500.c 11 Feb 2003 21:08:22 -0000 @@ -29,12 +29,14 @@ */ #include +#include #include #include #include #include #include #include +#include #include "avr.h" #include "pgm.h"