Submitted by someone who thinks he's called "Daper":

Fix bug #15013: Wrong use of PPICLAIM (kernel: ppdev0: claim the
port first)

* par.c: don't claim/release here (thus win_ppdev.h not needed
anymore)
* ppi.c: claim/release here.
* freebsd_ppi.h: ppi_claim/ppi_release now take an fd as parameter.
* solaris_ecpp.h: (Ditto.)
* linux_ppdev.h: (Ditto.)  (Also add copyright.)
* win_ppdev.h: Not needed anymore, remove.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@557 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2005-11-29 20:20:22 +00:00
parent f68ed0ca7a
commit dbe35b16f8
7 changed files with 52 additions and 28 deletions

View File

@ -1,3 +1,16 @@
2005-11-29 Joerg Wunsch <j@uriah.heep.sax.de>
Submitted by someone who thinks he's called "Daper":
Fix bug #15013: Wrong use of PPICLAIM (kernel: ppdev0: claim the
port first)
* par.c: don't claim/release here (thus win_ppdev.h not needed
anymore)
* ppi.c: claim/release here.
* freebsd_ppi.h: ppi_claim/ppi_release now take an fd as parameter.
* solaris_ecpp.h: (Ditto.)
* linux_ppdev.h: (Ditto.) (Also add copyright.)
* win_ppdev.h: Not needed anymore, remove.
2005-11-28 Joerg Wunsch <j@uriah.heep.sax.de>
* jtagmkI.c: Improve the communication startup with the ICE.

View File

@ -24,9 +24,9 @@
#include <dev/ppbus/ppi.h>
#define ppi_claim(pgm) {}
#define ppi_claim(fd) {}
#define ppi_release(pgm) {}
#define ppi_release(fd) {}
#define DO_PPI_READ(fd, reg, valp) \
(void)ioctl(fd, \

View File

@ -1,5 +1,26 @@
#ifndef __linux_ppdev_h__
#define __linux_ppdev_h__
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2003, 2005 Theodore A. Roth
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef linux_ppdev_h
#define linux_ppdev_h
#define OBSOLETE__IOW _IOW
@ -9,16 +30,16 @@
#include <stdlib.h>
#define ppi_claim(pgm) \
if (ioctl(pgm->fd, PPCLAIM)) { \
#define ppi_claim(fd) \
if (ioctl(fd, PPCLAIM)) { \
fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \
progname, port, strerror(errno)); \
close(pgm->fd); \
close(fd); \
exit(1); \
}
}
#define ppi_release(pgm) \
if (ioctl(pgm->fd, PPRELEASE)) { \
#define ppi_release(fd) \
if (ioctl(fd, PPRELEASE)) { \
fprintf(stderr, "%s: can't release device: %s\n\n", \
progname, strerror(errno)); \
exit(1); \
@ -33,4 +54,4 @@
(reg) == PPIDATA? PPWDATA: ((reg) == PPICTRL? PPWCONTROL: PPWSTATUS), \
valp)
#endif /* __linux_ppdev_h__ */
#endif /* linux_ppdev_h */

6
par.c
View File

@ -34,8 +34,6 @@
# include "linux_ppdev.h"
#elif defined(__sun__) && defined(__svr4__) /* Solaris */
# include "solaris_ecpp.h"
#elif defined(WIN32NATIVE)
# include "win_ppdev.h"
#endif
#include "avr.h"
@ -241,8 +239,6 @@ static int par_open(PROGRAMMER * pgm, char * port)
exit(1);
}
ppi_claim(pgm);
/*
* save pin values, so they can be restored when device is closed
*/
@ -274,8 +270,6 @@ static void par_close(PROGRAMMER * pgm)
ppi_setall(pgm->fd, PPIDATA, pgm->ppidata);
ppi_setall(pgm->fd, PPICTRL, pgm->ppictrl);
ppi_release(pgm);
ppi_close(pgm->fd);
pgm->fd = -1;
}

3
ppi.c
View File

@ -212,6 +212,8 @@ int ppi_open(char * port)
return -1;
}
ppi_claim (fd);
/*
* Initialize shadow registers
*/
@ -226,6 +228,7 @@ int ppi_open(char * port)
void ppi_close(int fd)
{
ppi_release (fd);
close(fd);
}

View File

@ -24,15 +24,15 @@
#include <sys/ecppio.h>
#define ppi_claim(pgm) \
#define ppi_claim(fd) \
do { \
struct ecpp_transfer_parms p; \
(void)ioctl(pgm->fd, ECPPIOC_GETPARMS, &p); \
(void)ioctl(fd, ECPPIOC_GETPARMS, &p); \
p.mode = ECPP_DIAG_MODE; \
(void)ioctl(pgm->fd, ECPPIOC_SETPARMS, &p); \
(void)ioctl(fd, ECPPIOC_SETPARMS, &p); \
} while(0);
#define ppi_release(pgm)
#define ppi_release(fd)
#define DO_PPI_READ(fd, reg, valp) \
do { struct ecpp_regs r; \

View File

@ -1,7 +0,0 @@
#ifndef win32native_ppdev_h__
#define win32native_ppdev_h__
#define ppi_claim(pgm)
#define ppi_release(pgm)
#endif win32native_ppdev_h__