flag out the only scsi specific code

Also flag out some places where code appears unused.
pull/29/head
Karl Palsson 2011-10-22 19:09:31 +00:00
rodzic 076f1086fa
commit 42d2da531f
7 zmienionych plików z 22 dodań i 18 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
##
VPATH=src
SOURCES_LIB=stlink-common.c stlink-usb.c #stlink-sg.c
SOURCES_LIB=stlink-common.c stlink-usb.c stlink-sg.c
OBJS_LIB=$(SOURCES_LIB:.c=.o)
TEST_PROGRAMS=test_usb #test_sg
LDFLAGS=-lusb-1.0 -L. -lstlink

Wyświetl plik

@ -1,5 +1,7 @@
/* simple wrapper around the stlink_flash_write function */
// TODO - this should be done as just a simple flag to the st-util command line...
#include <stdio.h>
#include <stdlib.h>
@ -87,7 +89,7 @@ int main(int ac, char** av)
if (o.devname != NULL) /* stlinkv1 */
{
static const int scsi_verbose = 2;
sl = stlink_quirk_open(o.devname, scsi_verbose);
sl = stlink_v1_open(o.devname, scsi_verbose);
if (sl == NULL) goto on_error;
}
else /* stlinkv2 */

Wyświetl plik

@ -207,7 +207,7 @@ int main(int argc, char** argv) {
const int X_index = 7;
DevName[X_index] = DevNum + '0';
if (!access(DevName, F_OK)) {
sl = stlink_quirk_open(DevName, 0);
sl = stlink_v1_open(DevName, 0);
ExistDevCount++;
}
} else if (DevNum < 100) {
@ -217,7 +217,7 @@ int main(int argc, char** argv) {
DevName[X_index] = DevNum / 10 + '0';
DevName[Y_index] = DevNum % 10 + '0';
if (!access(DevName, F_OK)) {
sl = stlink_quirk_open(DevName, 0);
sl = stlink_v1_open(DevName, 0);
ExistDevCount++;
}
}
@ -231,7 +231,7 @@ int main(int argc, char** argv) {
return 1;
}
} else {
sl = stlink_quirk_open(state.devicename, state.logging_level);
sl = stlink_v1_open(state.devicename, state.logging_level);
}
break;
}

Wyświetl plik

@ -82,12 +82,7 @@
#include "stlink-common.h"
#if CONFIG_USE_LIBSG
// sgutils2 (apt-get install libsgutils2-dev)
#include <scsi/sg_lib.h>
#include <scsi/sg_pt.h>
#include "stlink-sg.h"
#endif
// Suspends execution of the calling process for
@ -119,15 +114,18 @@ static void clear_buf(stlink_t *sl) {
void _stlink_sg_close(stlink_t *sl) {
if (sl) {
#if FINISHED_WITH_SG
struct stlink_libsg *slsg = sl->backend_data;
scsi_pt_close_device(slsg->sg_fd);
free(slsg);
#endif
}
}
//TODO rewrite/cleanup, save the error in sl
#if FINISHED_WITH_SG
static void stlink_confirm_inq(stlink_t *stl, struct sg_pt_base *ptvp) {
struct stlink_libsg *sl = stl->backend_data;
const int e = sl->do_scsi_pt_err;
@ -209,8 +207,10 @@ static void stlink_confirm_inq(stlink_t *stl, struct sg_pt_base *ptvp) {
"category (%d)\n", cat);
}
}
#endif
void stlink_q(stlink_t *sl) {
#if FINISHED_WITH_SG
struct stlink_libsg* sg = sl->backend_data;
DD(sl, "CDB[");
for (int i = 0; i < CDB_SL; i++)
@ -245,6 +245,7 @@ void stlink_q(stlink_t *sl) {
stlink_confirm_inq(sl, ptvp);
// TODO recycle: clear_scsi_pt_obj(struct sg_pt_base * objp);
destruct_scsi_pt_obj(ptvp);
#endif
}
// TODO thinking, cleanup
@ -803,7 +804,7 @@ stlink_t* stlink_open(const char *dev_name, const int verbose) {
stlink_t* stlink_quirk_open(const char *dev_name, const int verbose) {
stlink_t* stlink_v1_open(const char *dev_name, const int verbose) {
stlink_t *sl = stlink_open(dev_name, verbose);
if (sl == NULL) {

Wyświetl plik

@ -40,7 +40,6 @@ extern "C" {
#if defined(CONFIG_USE_LIBUSB)
struct stlink_libsg {
int sg_fd;
int do_scsi_pt_err;
@ -63,11 +62,8 @@ extern "C" {
reg reg;
};
#else
struct stlink_libsg {};
#endif
stlink_t* stlink_quirk_open(const char *dev_name, const int verbose);
stlink_t* stlink_v1_open(const char *dev_name, const int verbose);
#ifdef __cplusplus
}

Wyświetl plik

@ -116,7 +116,10 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate,
if (submit_wait(handle, handle->rep_trans)) return -1;
res = handle->rep_trans->actual_length;
}
if ((handle->protocoll == 1) && terminate) {
fprintf(stderr, "This is never used....\n");
exit(EXIT_FAILURE);
/* Read the SG reply */
unsigned char sg_buf[13];
libusb_fill_bulk_transfer
@ -172,6 +175,7 @@ static int fill_command
int i = 0;
memset(cmd, 0, sizeof (sl->c_buf));
if(slu->protocoll == 1) {
fprintf(stderr, "This is never used....\n");
cmd[i++] = 'U';
cmd[i++] = 'S';
cmd[i++] = 'B';
@ -652,11 +656,12 @@ stlink_t* stlink_open_usb(const int verbose) {
printf("libusb_alloc_transfer\n");
goto on_libusb_error;
}
// TODO - could use the scanning techniq from stm8 code here...
slu->ep_rep = 1 /* ep rep */ | LIBUSB_ENDPOINT_IN;
slu->ep_req = 2 /* ep req */ | LIBUSB_ENDPOINT_OUT;
slu->sg_transfer_idx = 0;
// TODO - never used at the moment, always CMD_SIZE
slu->cmd_len = (slu->protocoll == 1)? STLINK_SG_SIZE: STLINK_CMD_SIZE;
/* success */

Wyświetl plik

@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "Using sg_lib %s : scsi_pt %s\n", sg_lib_version(),
scsi_pt_version());
stlink_t *sl = stlink_quirk_open(dev_name, scsi_verbose);
stlink_t *sl = stlink_v1_open(dev_name, scsi_verbose);
if (sl == NULL)
return EXIT_FAILURE;