* usbasp: replaced exit statements by return statements
* usbasp: check valid handle on usbasp_close() call git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@943 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
59010a4b6f
commit
20a65eeeb8
17
usbasp.c
17
usbasp.c
|
@ -147,7 +147,7 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
||||||
5000);
|
5000);
|
||||||
if(nbytes < 0){
|
if(nbytes < 0){
|
||||||
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
|
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
|
||||||
exit(1);
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
nbytes = usb_control_msg(PDATA(pgm)->usbhandle,
|
nbytes = usb_control_msg(PDATA(pgm)->usbhandle,
|
||||||
|
@ -159,7 +159,7 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
||||||
5000);
|
5000);
|
||||||
if(nbytes < 0){
|
if(nbytes < 0){
|
||||||
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
|
fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
|
||||||
exit(1);
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return nbytes;
|
return nbytes;
|
||||||
|
@ -347,7 +347,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
||||||
"%s: error: could not find USB device "
|
"%s: error: could not find USB device "
|
||||||
"\"NIBObee\" with vid=0x%x pid=0x%x\n",
|
"\"NIBObee\" with vid=0x%x pid=0x%x\n",
|
||||||
progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
|
progname, USBASP_NIBOBEE_VID, USBASP_NIBOBEE_PID);
|
||||||
exit(1);
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_SHARED_VID, "www.fischl.de",
|
} else if (usbOpenDevice(&PDATA(pgm)->usbhandle, USBASP_SHARED_VID, "www.fischl.de",
|
||||||
|
@ -362,7 +362,7 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
||||||
"%s: error: could not find USB device "
|
"%s: error: could not find USB device "
|
||||||
"\"USBasp\" with vid=0x%x pid=0x%x\n",
|
"\"USBasp\" with vid=0x%x pid=0x%x\n",
|
||||||
progname, USBASP_SHARED_VID, USBASP_SHARED_PID);
|
progname, USBASP_SHARED_VID, USBASP_SHARED_PID);
|
||||||
exit(1);
|
return -1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -380,16 +380,17 @@ static int usbasp_open(PROGRAMMER * pgm, char * port)
|
||||||
|
|
||||||
static void usbasp_close(PROGRAMMER * pgm)
|
static void usbasp_close(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
|
if (PDATA(pgm)->usbhandle!=NULL) {
|
||||||
unsigned char temp[4];
|
unsigned char temp[4];
|
||||||
memset(temp, 0, sizeof(temp));
|
memset(temp, 0, sizeof(temp));
|
||||||
usbasp_transmit(pgm, 1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
|
usbasp_transmit(pgm, 1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
|
||||||
|
|
||||||
#ifdef USE_LIBUSB_1_0
|
#ifdef USE_LIBUSB_1_0
|
||||||
libusb_close(PDATA(pgm)->usbhandle);
|
libusb_close(PDATA(pgm)->usbhandle);
|
||||||
#else
|
#else
|
||||||
usb_close(PDATA(pgm)->usbhandle);
|
usb_close(PDATA(pgm)->usbhandle);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
|
static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
|
||||||
|
@ -544,7 +545,7 @@ static int usbasp_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
if (n != blocksize) {
|
if (n != blocksize) {
|
||||||
fprintf(stderr, "%s: error: wrong reading bytes %x\n",
|
fprintf(stderr, "%s: error: wrong reading bytes %x\n",
|
||||||
progname, n);
|
progname, n);
|
||||||
exit(1);
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer += blocksize;
|
buffer += blocksize;
|
||||||
|
@ -616,7 +617,7 @@ static int usbasp_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
if (n != blocksize) {
|
if (n != blocksize) {
|
||||||
fprintf(stderr, "%s: error: wrong count at writing %x\n",
|
fprintf(stderr, "%s: error: wrong count at writing %x\n",
|
||||||
progname, n);
|
progname, n);
|
||||||
exit(1);
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -754,7 +755,7 @@ static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
|
||||||
fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",
|
fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",
|
||||||
progname);
|
progname);
|
||||||
|
|
||||||
exit(1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbasp_initpgm(PROGRAMMER * pgm)
|
void usbasp_initpgm(PROGRAMMER * pgm)
|
||||||
|
|
Loading…
Reference in New Issue