1 /* finish.c - finalization of the driver operation
2 * Linux CAN-bus device driver.
3 * Written by Arnaud Westenberg email:arnaud@wanadoo.nl
4 * Rewritten for new CAN queues by Pavel Pisa - OCERA team member
5 * email:pisa@cmp.felk.cvut.cz
6 * This software is released under the GPL-License.
7 * Version lincan-0.3 17 Jun 2004
10 #include "./can/can.h"
11 #include "./can/can_sysless.h"
12 #include "./can/main.h"
13 #include "./can/devcommon.h"
14 #include "./can/finish.h"
15 #include "./can/setup.h"
19 * msgobj_done - destroys one CAN message object
20 * @obj: pointer to CAN message object structure
22 void msgobj_done(struct msgobj_t *obj)
26 delayed=canqueue_ends_done_chip(obj->qends);
28 CANMSG("msgobj_done: problem with chip queue ends\n");
31 if((obj->hostchip) && (obj->object>0)) {
32 if(obj->hostchip->msgobj[obj->object-1] == obj)
33 obj->hostchip->msgobj[obj->object-1]=NULL;
35 CANMSG("msgobj_done: not registered in the canchip_t\n");
40 if(objects_p[obj->minor] == obj)
41 objects_p[obj->minor] = NULL;
43 CANMSG("msgobj_done: not registered as minor\n");
46 // del_timer_sync(&obj->tx_timeout);
49 /*delayed free could be required there in the future,
50 actual use patter cannot generate such situation*/
60 * canchip_done - destroys one CAN chip representation
61 * @chip: pointer to CAN chip structure
63 void canchip_done(struct canchip_t *chip)
69 if(chip->flags & CHIP_ATTACHED)
70 chip->chipspecops->release_chip(chip);
72 if((chip->hostdevice) && (chip->chip_idx>=0)) {
73 if(chip->hostdevice->chip[chip->chip_idx] == chip)
74 chip->hostdevice->chip[chip->chip_idx] = NULL;
76 CANMSG("canchip_done: not registered in hostdevice\n");
79 // Not using interrupts
80 // can_chip_free_irq(chip);
82 // can_synchronize_irq(chip->chip_irq);
84 for(i=0; i<chip->max_objects; i++){
85 if((obj=chip->msgobj[i])==NULL)
91 free(chip->chipspecops);
92 chip->chipspecops=NULL;
97 * candevice_done - destroys representation of one CAN device/board
98 * @candev: pointer to CAN device/board structure
100 void candevice_done(struct candevice_t *candev)
103 struct canchip_t *chip;
105 for(i=0; i<candev->nr_all_chips; i++){
106 if((chip=candev->chip[i])==NULL)
112 if(candev->flags & CANDEV_IO_RESERVED) {
113 candev->hwspecops->release_io(candev);
114 candev->flags &= ~CANDEV_IO_RESERVED;
116 free(candev->hwspecops);
117 candev->hwspecops=NULL;
121 * candevice_done - destroys representation of all CAN devices/boards
122 * @canhw: pointer to the root of all CAN hardware representation
124 void canhardware_done(struct canhardware_t *canhw)
127 struct candevice_t *candev;
129 for(i=0; i<canhw->nr_boards; i++){
130 if((candev=canhw->candevice[i])==NULL)
132 candevice_done(candev);