* 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 inttypes header to quell compiler warning. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@184 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
6e82f6ee9c
commit
3176513162
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef __linux_ppdev_h__
|
||||||
|
#define __linux_ppdev_h__
|
||||||
|
|
||||||
|
#define OBSOLETE__IOW _IOW
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <linux/parport.h>
|
||||||
|
#include <linux/ppdev.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#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__ */
|
9
ppi.c
9
ppi.c
|
@ -25,7 +25,12 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
#include <dev/ppbus/ppi.h>
|
#include <dev/ppbus/ppi.h>
|
||||||
|
#elif defined(__linux__)
|
||||||
|
#include "linux_ppdev.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "avr.h"
|
#include "avr.h"
|
||||||
#include "pindefs.h"
|
#include "pindefs.h"
|
||||||
|
@ -760,11 +765,15 @@ void ppi_open(PROGRAMMER * pgm, char * port)
|
||||||
progname, port, strerror(errno));
|
progname, port, strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppi_claim(pgm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ppi_close(PROGRAMMER * pgm)
|
void ppi_close(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
|
ppi_release(pgm);
|
||||||
|
|
||||||
close(pgm->fd);
|
close(pgm->fd);
|
||||||
pgm->fd = -1;
|
pgm->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
6
ppi.h
6
ppi.h
|
@ -29,7 +29,13 @@ void ppi_initpgm (PROGRAMMER * pgm);
|
||||||
|
|
||||||
int ppi_getpinmask(int pin);
|
int ppi_getpinmask(int pin);
|
||||||
|
|
||||||
|
#if !defined(ppi_claim)
|
||||||
|
# define ppi_claim(pgm)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(ppi_release)
|
||||||
|
# define ppi_release(pgm)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue