]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Added check of usbcan device presence on registration
authorJan Kriz <krizj1@fel.cvut.cz>
Thu, 24 Jul 2008 09:44:01 +0000 (11:44 +0200)
committerppisa <pisa@cmp.felk.cvut.cz>
Sun, 23 Nov 2008 23:25:20 +0000 (00:25 +0100)
lincan/src/usbcan.c

index 1be7a9031225a224ae23175607bde197d09156b0..7980cc3464bd2382246d0c17ecb6bbf9aee30192 100644 (file)
@@ -47,6 +47,12 @@ int usbcan_request_io(struct candevice_t *candev)
 {
        struct usbcan_usb *dev = (struct usbcan_usb*)candev->sysdevptr.anydev;
 
+       if (!dev){
+               CANMSG("Cannot register usbcan while usb device is not present.\n");
+               CANMSG("Usbcan registers automatically on device insertion.\n");
+               return -ENODEV;
+       }
+
        /* start kernel thread */
        dev->rcvthread.arg = dev;
        start_kthread(usbcan_read_kthread, &dev->rcvthread);