From 556b3eddb30fc392e9b6c6985384a579f45b1caa Mon Sep 17 00:00:00 2001
From: Hannes Weisbach <hannes_weisbach@gmx.net>
Date: Mon, 6 May 2013 11:48:08 +0000
Subject: [PATCH] avrftdi: Use pgm->setpin instead of pgm->cookie->set_pin

avrftdi.c: remove set_pin init, add pgm->setpin init
avrftdi_private.h: remove avrftdi_t->set_pin member
avrftdi_tpi.c: change avrftdi_t->set_pin calls to pgm->setpin.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1163 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog         |  7 +++++++
 avrftdi.c         |  3 ++-
 avrftdi_private.h |  5 -----
 avrftdi_tpi.c     | 10 +++++-----
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1ac9abe5..3aea788a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-06  Hannes Weisbach <hannes_weisbach@gmx.net>
+
+	* avrftdi_tpi.c: instead of private set_pin() function pointer use the one
+	declared in struct PROGRAMMER.
+	* avrftdi_private.h: remove set_pin function pointer
+	* avrftdi.c: remove set_pin function pointer init, add pgm->setpin init.
+
 2013-05-06  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	* pindefs.h: Include "ac_cfg.h" before testing for HAVE_* macros.
diff --git a/avrftdi.c b/avrftdi.c
index 1742919a..ff107042 100644
--- a/avrftdi.c
+++ b/avrftdi.c
@@ -1276,7 +1276,6 @@ avrftdi_setup(PROGRAMMER * pgm)
 	pdata->pin_value = 0;
 	pdata->pin_direction = 0;
 	pdata->led_mask = 0;
-	pdata->set_pin = &set_pin;
 }
 
 static void
@@ -1324,6 +1323,8 @@ void avrftdi_initpgm(PROGRAMMER * pgm)
 	pgm->paged_write = avrftdi_paged_write;
 	pgm->paged_load = avrftdi_paged_load;
 
+	pgm->setpin = set_pin;
+
 	pgm->setup = avrftdi_setup;
 	pgm->teardown = avrftdi_teardown;
 
diff --git a/avrftdi_private.h b/avrftdi_private.h
index 45361bbd..0087db22 100644
--- a/avrftdi_private.h
+++ b/avrftdi_private.h
@@ -64,11 +64,6 @@ typedef struct avrftdi_s {
 	int pin_limit;
 	/* internal RX buffer of the device. needed for INOUT transfers */
 	int rx_buffer_size;
-	/* function pointer to the set_pin function, so that we do not have to drag
-	 * it into global scope. it's a hack, but i think it's slightly better than
-	 * the alternative.
-	 */
-	int (*set_pin)(PROGRAMMER *, int, int);
 } avrftdi_t;
 
 void avrftdi_log(int level, const char * func, int line, const char * fmt, ...);
diff --git a/avrftdi_tpi.c b/avrftdi_tpi.c
index 6f14196c..cdcc8631 100644
--- a/avrftdi_tpi.c
+++ b/avrftdi_tpi.c
@@ -86,17 +86,17 @@ avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p)
 	pgm->paged_write = NULL;
 
 	log_info("Setting /Reset pin low\n");
-	pdata->set_pin(pgm, PIN_AVR_RESET, OFF);
-	pdata->set_pin(pgm, PIN_AVR_SCK, OFF);
-	pdata->set_pin(pgm, PIN_AVR_MOSI, ON);
+	pgm->setpin(pgm, PIN_AVR_RESET, OFF);
+	pgm->setpin(pgm, PIN_AVR_SCK, OFF);
+	pgm->setpin(pgm, PIN_AVR_MOSI, ON);
 	usleep(20 * 1000);
 
-	pdata->set_pin(pgm, PIN_AVR_RESET, ON);
+	pgm->setpin(pgm, PIN_AVR_RESET, ON);
 	/* worst case 128ms */
 	usleep(2 * 128 * 1000);
 
 	/*setting rst back to 0 */
-	pdata->set_pin(pgm, PIN_AVR_RESET, OFF);
+	pgm->setpin(pgm, PIN_AVR_RESET, OFF);
 	/*wait at least 20ms bevor issuing spi commands to avr */
 	usleep(20 * 1000);