Serial Hub fixes... Thanks James.
--- a/drivers/can_serial/can_serial_hub.c Mon Apr 28 11:20:19 2008 +0200
+++ b/drivers/can_serial/can_serial_hub.c Mon Apr 28 11:21:33 2008 +0200
@@ -190,7 +190,7 @@
Message m;
int rv, i;
fd_set wfds_copy;
- struct timeval tv = {.tv_sec = 0, .tv_usec = 0}; //wait 1 msec
+ struct timeval tv = {.tv_sec = 0, .tv_usec = 0}; //wait 0 msec
if (rd_port == MAX_HUB_PORTS) {
rv = DLL_CALL(canReceive)(h, &m);
@@ -221,7 +221,7 @@
continue;
}
- if (rv <= 0 || !FD_ISSET(p[i].fd, &wfds_copy)) {
+ if (p[i].fd < 0 || !FD_ISSET(p[i].fd, &wfds_copy)) {
fprintf(stderr, "{%d} ", i);
continue;
}
@@ -428,7 +428,8 @@
//as timeout is NULL, must be a rfds set.
for (i = 0; i < MAX_HUB_PORTS + 1; i++) {
- if (FD_ISSET(hub_ports[i].fd, &rfds_copy)) {
+ if (hub_ports[i].fd >= 0 &&
+ FD_ISSET(hub_ports[i].fd, &rfds_copy)) {
rv = read_write(i, hub_ports, can_h, &rfds, max_fd);
@@ -437,20 +438,19 @@
FD_CLR(hub_ports[i].fd, &rfds);
hub_close(&hub_ports[i]);
-
- rv = hub_open(&hub_ports[i]);
-
- if (rv < 0) {
- ret = 1;
- break;
- }
-
+ }
+ }
+
+ if (hub_ports[i].fd < 0 && i < MAX_HUB_PORTS) {
+ rv = hub_open(&hub_ports[i]);
+
+ if (rv >= 0) {
FD_SET(rv, &rfds);
if (rv > max_fd) {
max_fd = rv;
- }
- }
+ }
+ }
}
}
}