Use already cached fp rather than constantly re-opening things on the fly.

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1830 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent b7a7d2131e
commit c00e9e68d7

@ -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 <vapier@gentoo.org>
* configure.ac (AC_CHECK_FUNCS): Check for _sleep.

@ -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

Loading…
Cancel
Save