diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 01133be6..6ffc3432 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -4,6 +4,9 @@ src/tap/Makefile.am: Add vsllink cable driver to cable lists. * src/tap/cable/vsllink.c: New cable driver by Simon Qian. + * src/tap/cable/gpio.c (gpio_get_value): Use already cached fp rather than + constantly re-opening things on the fly. + 2010-08-18 Mike Frysinger * configure.ac (AC_CHECK_FUNCS): Check for _sleep. diff --git a/urjtag/src/tap/cable/gpio.c b/urjtag/src/tap/cable/gpio.c index 02472a11..6e4c2c73 100644 --- a/urjtag/src/tap/cable/gpio.c +++ b/urjtag/src/tap/cable/gpio.c @@ -127,26 +127,12 @@ static int gpio_set_value (FILE *fp, int value) return URJ_STATUS_OK; } -static int gpio_get_value (unsigned int gpio) +static int gpio_get_value (FILE *fp, unsigned int gpio) { int ret; int value; - char fname[50]; - FILE *fp; - - snprintf (fname, sizeof (fname), - "%sgpio%u/value", GPIO_PATH, gpio); - fname[sizeof (fname) - 1] = '\0'; - - fp = fopen (fname, "r"); - if (!fp) - { - urj_warning (_("%s: cannot open to read GPIO %u\n"), fname, gpio); - return URJ_STATUS_FAIL; - } ret = fscanf (fp, "%i", &value); - fclose (fp); if (ret != 1) { @@ -355,7 +341,7 @@ gpio_get_tdo ( urj_cable_t *cable ) urj_tap_cable_wait (cable); - return (gpio_get_value (p->jtag_gpios[GPIO_TDO])); + return gpio_get_value (p->fp_gpios[GPIO_TDO], p->jtag_gpios[GPIO_TDO]); } static int