Browse Source

Merge commit '2e20d06' into bfgminer-3.2.x

Luke Dashjr 12 years ago
parent
commit
03780f4b32
5 changed files with 12 additions and 4 deletions
  1. 1 1
      driver-bitforce.c
  2. 1 1
      driver-icarus.c
  3. 1 1
      driver-modminer.c
  4. 8 0
      fpgautils.c
  5. 1 1
      fpgautils.h

+ 1 - 1
driver-bitforce.c

@@ -144,7 +144,7 @@ void bitforce_cmd2(int fd, int procid, void *buf, size_t bufsz, const char *cmd,
 	BFgets(buf, bufsz, fd);
 	BFgets(buf, bufsz, fd);
 }
 }
 
 
-#define BFclose(fd) close(fd)
+#define BFclose(fd) serial_close(fd)
 
 
 struct bitforce_init_data {
 struct bitforce_init_data {
 	bool sc;
 	bool sc;

+ 1 - 1
driver-icarus.c

@@ -295,7 +295,7 @@ static int icarus_write(int fd, const void *buf, size_t bufLen)
 	return 0;
 	return 0;
 }
 }
 
 
-#define icarus_close(fd) close(fd)
+#define icarus_close(fd) serial_close(fd)
 
 
 static void do_icarus_close(struct thr_info *thr)
 static void do_icarus_close(struct thr_info *thr)
 {
 {

+ 1 - 1
driver-modminer.c

@@ -173,7 +173,7 @@ modminer_detect()
 static bool
 static bool
 modminer_reopen(struct cgpu_info*modminer)
 modminer_reopen(struct cgpu_info*modminer)
 {
 {
-	close(modminer->device->device_fd);
+	serial_close(modminer->device->device_fd);
 	int fd = serial_open(modminer->device_path, 0, 10, true);
 	int fd = serial_open(modminer->device_path, 0, 10, true);
 	if (unlikely(-1 == fd)) {
 	if (unlikely(-1 == fd)) {
 		applog(LOG_ERR, "%s: Failed to reopen %s", modminer->dev_repr, modminer->device_path);
 		applog(LOG_ERR, "%s: Failed to reopen %s", modminer->dev_repr, modminer->device_path);

+ 8 - 0
fpgautils.c

@@ -898,6 +898,14 @@ int serial_open(const char *devpath, unsigned long baud, uint8_t timeout, bool p
 #endif
 #endif
 }
 }
 
 
+int serial_close(const int fd)
+{
+#if defined(LOCK_EX) && defined(LOCK_NB) && defined(LOCK_UN)
+	flock(fd, LOCK_UN);
+#endif
+	return close(fd);
+}
+
 ssize_t _serial_read(int fd, char *buf, size_t bufsiz, char *eol)
 ssize_t _serial_read(int fd, char *buf, size_t bufsiz, char *eol)
 {
 {
 	ssize_t len, tlen = 0;
 	ssize_t len, tlen = 0;

+ 1 - 1
fpgautils.h

@@ -44,7 +44,7 @@ extern ssize_t _serial_read(int fd, char *buf, size_t buflen, char *eol);
 	_serial_read(fd, (char*)(buf), count, NULL)
 	_serial_read(fd, (char*)(buf), count, NULL)
 #define serial_read_line(fd, buf, bufsiz, eol)  \
 #define serial_read_line(fd, buf, bufsiz, eol)  \
 	_serial_read(fd, buf, bufsiz, &eol)
 	_serial_read(fd, buf, bufsiz, &eol)
-#define serial_close(fd)  close(fd)
+extern int serial_close(int fd);
 
 
 extern void _bitstream_not_found(const char *repr, const char *fn);
 extern void _bitstream_not_found(const char *repr, const char *fn);
 extern FILE *open_xilinx_bitstream(const char *dname, const char *repr, const char *fwfile, unsigned long *out_len);
 extern FILE *open_xilinx_bitstream(const char *dname, const char *repr, const char *fwfile, unsigned long *out_len);