Skip to content

Commit

Permalink
Submitted by someone who thinks he's called "Daper":
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joerg_wunsch committed Nov 29, 2005
1 parent 1d0addb commit c1e3818
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 28 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2005-11-29 Joerg Wunsch <[email protected]>

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 <[email protected]>

* jtagmkI.c: Improve the communication startup with the ICE.
Expand Down
4 changes: 2 additions & 2 deletions freebsd_ppi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
39 changes: 30 additions & 9 deletions linux_ppdev.h
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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); \
Expand All @@ -33,4 +54,4 @@
(reg) == PPIDATA? PPWDATA: ((reg) == PPICTRL? PPWCONTROL: PPWSTATUS), \
valp)

#endif /* __linux_ppdev_h__ */
#endif /* linux_ppdev_h */
6 changes: 0 additions & 6 deletions par.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions ppi.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ int ppi_open(char * port)
return -1;
}

ppi_claim (fd);

/*
* Initialize shadow registers
*/
Expand All @@ -226,6 +228,7 @@ int ppi_open(char * port)

void ppi_close(int fd)
{
ppi_release (fd);
close(fd);
}

Expand Down
8 changes: 4 additions & 4 deletions solaris_ecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
7 changes: 0 additions & 7 deletions win_ppdev.h

This file was deleted.

0 comments on commit c1e3818

Please sign in to comment.