]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Applied James patch that fixes can_cn4linux.c file descriptor handling and make it...
authoretisserant <etisserant>
Wed, 4 Jun 2008 08:59:09 +0000 (08:59 +0000)
committeretisserant <etisserant>
Wed, 4 Jun 2008 08:59:09 +0000 (08:59 +0000)
drivers/can_can4linux/can_can4linux.c

index 093d49c1c6b7a53713d3440375fd14e9edc412db..cc949b6def9d2cea40ed8bdca579bea95397c44e 100755 (executable)
@@ -168,7 +168,7 @@ CAN_HANDLE canOpen_driver(s_BOARD *board)
   dev_name[prefix_len+name_len] = 0;
 
   fd0 = open(dev_name, O_RDWR|o_flags);
-  if(fd0 <= 0){
+  if(fd0 == -1){
     fprintf(stderr,"!!! %s is unknown. See can4linux.c\n", dev_name);
     goto error_ret;
   }
@@ -192,8 +192,16 @@ CAN_HANDLE canOpen_driver(s_BOARD *board)
 /***************************************************************************/
 int canClose_driver(CAN_HANDLE fd0)
 {
-  if((int)fd0<=0)
-    return -1;
-  close(fd0);
-  return 0;
+  if((int)fd0 != -1) {
+      return close((int)fd0);
+  }
+
+  return -1;
+}
+
+int canfd_driver(CAN_HANDLE fd0)
+{
+        return ((int)fd0);
 }
+
+