X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/fdf877c54ec2598864f6193e8e1fbaedb5c05efb..refs/heads/can-usb1:/lincan/src/close.c diff --git a/lincan/src/close.c b/lincan/src/close.c index 157acfa..6a0ca6e 100644 --- a/lincan/src/close.c +++ b/lincan/src/close.c @@ -49,19 +49,20 @@ int can_close(struct inode *inode, struct file *file) struct canque_ends_t *qends; struct msgobj_t *obj; can_spin_irqflags_t iflags; - + int minor_nr = INODE2MINOR_NR(inode); + if(!canuser || (canuser->magic != CAN_USER_MAGIC)){ CANMSG("can_close: bad canuser magic\n"); return -ENODEV; } - if ((chip=objects_p[MINOR_NR]->hostchip) == NULL) { - CANMSG("There is no hardware support for the device file with minor nr.: %d\n",MINOR_NR); + if ((chip=objects_p[minor_nr]->hostchip) == NULL) { + CANMSG("There is no hardware support for the device file with minor nr.: %d\n",minor_nr); return -ENODEV; } - + obj = canuser->msgobj; qends = canuser->qends; - + #ifdef CAN_ENABLE_KERN_FASYNC can_fasync(-1, file, 0); @@ -81,7 +82,7 @@ int can_close(struct inode *inode, struct file *file) can_msgobj_clear_fl(obj,OPENED); }; can_spin_unlock_irqrestore(&canuser_manipulation_lock, iflags); - + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,50)) MOD_DEC_USE_COUNT; #endif