From 70fdf3082ec722437ceefbee1a96dfb30c407cfb Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Tue, 29 Nov 2005 20:20:22 +0000 Subject: [PATCH] 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@557 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrdude/ChangeLog | 13 +++++++++++++ avrdude/freebsd_ppi.h | 4 ++-- avrdude/linux_ppdev.h | 39 ++++++++++++++++++++++++++++++--------- avrdude/par.c | 6 ------ avrdude/ppi.c | 3 +++ avrdude/solaris_ecpp.h | 8 ++++---- avrdude/win_ppdev.h | 7 ------- 7 files changed, 52 insertions(+), 28 deletions(-) delete mode 100644 avrdude/win_ppdev.h diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index d297cd03..ebe88435 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,16 @@ +2005-11-29 Joerg Wunsch + + 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 * jtagmkI.c: Improve the communication startup with the ICE. diff --git a/avrdude/freebsd_ppi.h b/avrdude/freebsd_ppi.h index 93e076ce..0885fc43 100644 --- a/avrdude/freebsd_ppi.h +++ b/avrdude/freebsd_ppi.h @@ -24,9 +24,9 @@ #include -#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, \ diff --git a/avrdude/linux_ppdev.h b/avrdude/linux_ppdev.h index 1fa36ef1..15043961 100644 --- a/avrdude/linux_ppdev.h +++ b/avrdude/linux_ppdev.h @@ -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 -#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 */ diff --git a/avrdude/par.c b/avrdude/par.c index b642acf3..3303856f 100644 --- a/avrdude/par.c +++ b/avrdude/par.c @@ -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; } diff --git a/avrdude/ppi.c b/avrdude/ppi.c index bd9798d8..61502949 100644 --- a/avrdude/ppi.c +++ b/avrdude/ppi.c @@ -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); } diff --git a/avrdude/solaris_ecpp.h b/avrdude/solaris_ecpp.h index 7179f0d6..b6812439 100644 --- a/avrdude/solaris_ecpp.h +++ b/avrdude/solaris_ecpp.h @@ -24,15 +24,15 @@ #include -#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; \ diff --git a/avrdude/win_ppdev.h b/avrdude/win_ppdev.h deleted file mode 100644 index 621665ea..00000000 --- a/avrdude/win_ppdev.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef win32native_ppdev_h__ -#define win32native_ppdev_h__ - -#define ppi_claim(pgm) -#define ppi_release(pgm) - -#endif win32native_ppdev_h__