[dahdi-commits] dahdi/tools.git branch "master" updated.

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Tue May 27 06:02:32 CDT 2014


branch "master" has been updated
       via  9285e86492b2e8477b0fb3aba143ca7038204873 (commit)
       via  ca7c04e9cbdfc182c9c9672dec884f5ac87f90b9 (commit)
       via  ae02edacb44c3fe0e7f43fc58f4265e922592cad (commit)
      from  2abfd165ae9d6f91d003e84b7efa8926f1b4defb (commit)

Summary of changes:
 xpp/Makefile      |   43 ++++++++++++++++++++-------
 xpp/echo_loader.c |    8 +++--
 xpp/xtalk/xusb.c  |   86 +++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 116 insertions(+), 21 deletions(-)


- Log -----------------------------------------------------------------
commit 9285e86492b2e8477b0fb3aba143ca7038204873
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Sun May 11 11:48:07 2014 -0400

    xpp: better error checking (echo_loader)
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/echo_loader.c b/xpp/echo_loader.c
index c81147f..2291214 100644
--- a/xpp/echo_loader.c
+++ b/xpp/echo_loader.c
@@ -362,7 +362,7 @@ int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
 	DBG("Loading %s file...\n", filename);
 	pFile = fopen(filename, "rb");
 	if (pFile == NULL) {
-		ERR("fopen\n");
+		ERR("fopen: %s\n", strerror(errno));
 		return -ENODEV;
 	}
 
@@ -378,7 +378,11 @@ int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
 	} else {
 		DBG("allocated mem for pbyFileData\n");
 	}
-	fread(pbyFileData, 1, *pLen, pFile);
+	if (fread(pbyFileData, 1, *pLen, pFile) != *pLen) {
+		fclose(pFile);
+		ERR("fread: %s\n", strerror(errno));
+		return -ENODEV;
+	}
 	fclose(pFile);
 	DBG("Successful loading %s file into memory "
 		"(size = %d, DUMP: first = %02X %02X, last = %02X %02X)\n",

commit ca7c04e9cbdfc182c9c9672dec884f5ac87f90b9
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Sun May 11 09:41:46 2014 -0400

    xpp: fix usb "clear_halt" problem
    
     * Don't use "usb_clear_halt" by default anymore
       - It caused problems with specific devices in the past
       - Now it cause problems with specific servers as well (64 bits, USB3)
    
     * Add an "XTALK_OPTIONS" environment variable to pass options:
       - Use it to implement a "use-clear-halt" boolean option that
         restore original behavior.
       - Also use it for "no-lock" option which replace the legacy
         environment variable "XUSB_NOLOCK".

diff --git a/xpp/xtalk/xusb.c b/xpp/xtalk/xusb.c
index 70bc656..dcc694a 100644
--- a/xpp/xtalk/xusb.c
+++ b/xpp/xtalk/xusb.c
@@ -61,6 +61,21 @@ struct xusb {
 
 static void xusb_init();
 
+/*
+ * XTALK_OPTIONS:
+ *     A white-space separated list of options, read from the environment
+ *     variable of that name. Existing options:
+ *
+ *     - "use-clear-halt" -- force USB "clear_halt" operation during
+ *                           device initialization
+ *     - "no-lock" -- prevent using global sempahore to serialize libusb
+ *                    initialization. Previously done via "XUSB_NOLOCK"
+ *                    environment variable.
+ */
+int xtalk_parse_options(void);
+int xtalk_option_use_clear_halt(void);
+int xtalk_option_no_lock(void);
+
 void xusb_init_spec(struct xusb_spec *spec, char *name,
 		uint16_t vendor_id, uint16_t product_id,
 		int nifaces, int iface, int nep, int ep_out, int ep_in)
@@ -257,13 +272,16 @@ int xusb_claim_interface(struct xusb *xusb)
 		xusb->iProduct,
 		xusb->iSerialNumber,
 		xusb->iInterface);
-	if (usb_clear_halt(xusb->handle, EP_OUT(xusb)) != 0) {
-		ERR("Clearing output endpoint: %s\n", usb_strerror());
-		return 0;
-	}
-	if (usb_clear_halt(xusb->handle, EP_IN(xusb)) != 0) {
-		ERR("Clearing input endpoint: %s\n", usb_strerror());
-		return 0;
+	if (xtalk_option_use_clear_halt()) {
+		DBG("Using clear_halt()\n");
+		if (usb_clear_halt(xusb->handle, EP_OUT(xusb)) != 0) {
+			ERR("Clearing output endpoint: %s\n", usb_strerror());
+			return 0;
+		}
+		if (usb_clear_halt(xusb->handle, EP_IN(xusb)) != 0) {
+			ERR("Clearing input endpoint: %s\n", usb_strerror());
+			return 0;
+		}
 	}
 	ret = xusb_flushread(xusb);
 	if (ret < 0) {
@@ -857,13 +875,63 @@ static int		initizalized;
 static void xusb_init()
 {
 	if (!initizalized) {
-		if (!getenv("XUSB_NOLOCK"))
+		xtalk_parse_options();
+		if (!xtalk_option_no_lock())
 			xusb_lock_usb();
 		usb_init();
 		usb_find_busses();
 		usb_find_devices();
 		initizalized = 1;
-		if (!getenv("XUSB_NOLOCK"))
+		if (!xtalk_option_no_lock())
 			xusb_unlock_usb();
 	}
 }
+
+/* XTALK option handling */
+static int use_clear_halt = 0;
+static int libusb_no_lock = 0;
+
+static int xtalk_one_option(const char *option_string)
+{
+	if (strcmp(option_string, "use-clear-halt") == 0) {
+		use_clear_halt = 1;
+		return 0;
+	}
+	if (strcmp(option_string, "no-lock") == 0) {
+		libusb_no_lock = 1;
+		return 0;
+	}
+	ERR("Unknown XTALK_OPTIONS content: '%s'\n", option_string);
+	return -EINVAL;
+}
+
+int xtalk_option_use_clear_halt(void)
+{
+	return use_clear_halt;
+}
+
+int xtalk_option_no_lock(void)
+{
+	return libusb_no_lock;
+}
+
+int xtalk_parse_options(void)
+{
+	char *xtalk_options;
+	char *saveptr;
+	char *token;
+	int ret;
+
+	xtalk_options = getenv("XTALK_OPTIONS");
+	if (!xtalk_options)
+		return 0;
+	token = strtok_r(xtalk_options, " \t", &saveptr);
+	while (token) {
+		ret = xtalk_one_option(token);
+		if (ret < 0)
+			return ret;
+		token = strtok_r(NULL, " \t", &saveptr);
+	}
+	return 0;
+}
+

commit ae02edacb44c3fe0e7f43fc58f4265e922592cad
Author: Oron Peled <oron.peled at xorcom.com>
Date:   Sun May 4 11:09:05 2014 -0400

    xpp: safer compilation
    
    * Compile with "-Wall -Werror"
    * Better dependency calculation:
      - Explicit listing of sources, don't use wildcards.
      - Pass various CFLAGS to dependency calculation as well.
      - Make sure a failure is propagated
    
    Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

diff --git a/xpp/Makefile b/xpp/Makefile
index 49f7b33..ee15fe1 100644
--- a/xpp/Makefile
+++ b/xpp/Makefile
@@ -54,7 +54,8 @@ OCT_DEFINES	= \
 	-DcOCT6100_MAX_ECHO_CHANNELS=672		\
 	-DcOCT6100_MAX_MIXER_EVENTS=1344
 
-ECHO_LOADER	= echo_loader.o
+ECHO_LOADER_SRC	= echo_loader.c
+ECHO_LOADER	= $(ECHO_LOADER_SRC:.c=.o)
 endif
 
 %.8: %
@@ -71,12 +72,33 @@ PERL_SCRIPTS	=	\
 
 PERL_MANS	= $(PERL_SCRIPTS:%=%.8)
 
-XTALK_OBJS		= xtalk/xtalk.o xtalk/xusb.o xtalk/xlist.o xtalk/debug.o
-ASTRIBANK_OBJS		= astribank_usb.o mpptalk.o $(XTALK_OBJS)
-
-ABHEXLOAD_OBJS		= astribank_hexload.o hexfile.o pic_loader.o $(ECHO_LOADER) $(ASTRIBANK_OBJS) $(OCT_HERE_OBJS)
-ABTOOL_OBJS		= astribank_tool.o $(ASTRIBANK_OBJS)
-ABALLOW_OBJS		= astribank_allow.o astribank_license.o $(ASTRIBANK_OBJS)
+# List all our sources
+XUSB_SRCS		= xtalk/xusb.c xtalk/xlist.c xtalk/debug.c
+XTALK_SRCS		= xtalk/xtalk.c
+MPPTALK_SRCS		= mpptalk.c
+ASTRIBANK_SRCS		= astribank_usb.c
+ABHEXLOAD_SRCS		= astribank_hexload.c hexfile.c pic_loader.c
+ABTOOL_SRCS		= astribank_tool.c
+ABALLOW_SRCS		= astribank_allow.c astribank_license.c
+
+SRCS	= \
+	$(XUSB_SRCS)	\
+	$(XTALK_SRCS)	\
+	$(MPPTALK_SRCS)	\
+	$(ASTRIBANK_SRCS)	\
+	$(ABHEXLOAD_SRCS)	\
+	$(ABTOOL_SRCS)	\
+	$(ABALLOW_SRCS)	\
+	$(ECHO_LOADER_SRC)
+
+# Derive object files from source list
+XUSB_OBJS		= $(XUSB_SRCS:.c=.o)
+XTALK_OBJS		= $(XTALK_SRCS:.c=.o) $(XUSB_OBJS)
+MPPTALK_OBJS		= $(MPPTALK_SRCS:.c=.o) $(XTALK_OBJS)
+ASTRIBANK_OBJS		= $(ASTRIBANK_SRCS:.c=.o) $(MPPTALK_OBJS)
+ABHEXLOAD_OBJS		= $(ABHEXLOAD_SRCS:.c=.o) $(ASTRIBANK_OBJS) $(ECHO_LOADER) $(OCT_HERE_OBJS)
+ABTOOL_OBJS		= $(ABTOOL_SRCS:.c=.o) $(ASTRIBANK_OBJS)
+ABALLOW_OBJS		= $(ABALLOW_SRCS:.c=.o) $(ASTRIBANK_OBJS)
 
 TARGETS	= .perlcheck astribank_is_starting
 PROG_INSTALL	= astribank_is_starting
@@ -124,7 +146,7 @@ ifneq	(,$(PERLLIBDIR))
 	done
 endif
 
-CFLAGS		+= -I. -Ixtalk
+CFLAGS		+= -I. -Ixtalk -Wall -Werror
 
 astribank_hexload: $(ABHEXLOAD_OBJS)
 astribank_hexload: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
@@ -171,7 +193,8 @@ clean:
 
 .PHONY: depend
 depend: .depend
-.depend: *.c *.h xtalk/*.c xtalk/*.h
-	@$(CC) $(CFLAGS) -MM *.c xtalk/*.c > $@ || rm -f $@
+.depend: *.c *.h xtalk/*.c
+	@echo "Calculating dependencies"
+	@if ! $(CC) $(CFLAGS) $(OCT_CFLAGS) -MM $(SRCS) > $@; then $(RM) $@; exit 1; fi
 
 include .depend

-----------------------------------------------------------------------


-- 
dahdi/tools.git



More information about the dahdi-commits mailing list