#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/time.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
+ #include <linux/kref.h>
+#endif
#include <asm/errno.h>
#include <asm/io.h>
#endif
#endif
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+ #define can_pci_dev_get(_M_pdev) (_M_pdev)
+ #define can_pci_dev_put(_M_pdev) do {} while(0)
+ #define can_pci_get_device pci_find_device
+ #define can_pci_get_subsys pci_find_subsys
+ #else /* > 2.6.0 */
+ #define can_pci_dev_get pci_dev_get
+ #define can_pci_dev_put pci_dev_put
+ #define can_pci_get_device pci_get_device
+ #define can_pci_get_subsys pci_get_subsys
+ #endif
+
#ifndef CAN_WITH_RTL
/* Standard LINUX kernel */
#endif /*CAN_WITH_RTL*/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4))
+ #include <linux/kthread.h>
+ #define can_kthread_create kthread_create
+ #define can_kthread_run kthread_run
+ #define can_kthread_bind kthread_bind
+ #define can_kthread_stop kthread_stop
+ #define can_kthread_should_stop kthread_should_stop
+#else
+ #define can_kthread_create
+ #define can_kthread_run
+ #define can_kthread_bind
+ #define can_kthread_stop
+ #define can_kthread_should_stop
+#endif
+
+
#endif /*_CAN_SYSDEP_H*/
struct canhardware_t *hosthardware_p;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
+ struct kref refcount;
+#endif
+
union {
void *anydev;
#ifdef CAN_ENABLE_PCI_SUPPORT
int chip_idx; /* chip index in candevice_t.chip[] */
int chip_irq;
can_ioptr_t chip_base_addr;
- unsigned int flags;
+ uint16_t flags;
long clock; /* Chip clock in Hz */
long baudrate;
int (*release_io)(struct candevice_t *candev);
int (*reset)(struct candevice_t *candev);
int (*init_hw_data)(struct candevice_t *candev);
+ void (*done_hw_data)(struct candevice_t *candev);
int (*init_chip_data)(struct candevice_t *candev, int chipnr);
int (*init_obj_data)(struct canchip_t *chip, int objnr);
int (*program_irq)(struct candevice_t *candev);
void (*write_register)(unsigned data, can_ioptr_t address);
unsigned (*read_register)(can_ioptr_t address);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
+ void (*release_device)(struct kref *refcount);
+#endif
+
};
/**
int can_request_mem_region(unsigned long start, unsigned long n, const char *name);
void can_release_mem_region(unsigned long start, unsigned long n);
+ #ifdef CAN_ENABLE_PCI_SUPPORT
+ struct pci_dev *can_pci_get_next_untaken_device(unsigned int vendor, unsigned int device);
+ struct pci_dev *can_pci_get_next_untaken_subsyst(unsigned int vendor, unsigned int device,
+ unsigned int ss_vendor, unsigned int ss_device);
+ #endif /*CAN_ENABLE_PCI_SUPPORT*/
+
struct boardtype_t {
const char *boardtype;
int (*board_register)(struct hwspecops_t *hwspecops);
#ifdef CAN_WITH_RTL
extern int can_rtl_priority;
#endif /*CAN_WITH_RTL*/
+
+extern struct candevice_t* register_hotplug_dev(const char *hwname,int (*chipdataregfnc)(struct canchip_t *chip,void *data),void *devdata);
+extern void deregister_hotplug_dev(struct candevice_t *dev);
+extern void cleanup_hotplug_dev(struct candevice_t *dev);
#include "../include/finish.h"
#include "../include/setup.h"
-
+extern int next_minor;
/**
* msgobj_done - destroys one CAN message object
* @obj: pointer to CAN message object structure
}
if((obj->minor>=0)) {
- if(objects_p[obj->minor] == obj)
+ if(objects_p[obj->minor] == obj){
objects_p[obj->minor] = NULL;
+ if (--next_minor<0)
+ next_minor=0;
+ }
else
CANMSG("msgobj_done: not registered as minor\n");
}
}
can_checked_free(chip->chipspecops);
+
+ if(~chip->flags & CHIP_KEEP_DATA)
+ can_checked_free(chip->chip_data);
+ chip->chip_data = NULL;
chip->chipspecops=NULL;
}
candev->hwspecops->release_io(candev);
candev->flags &= ~CANDEV_IO_RESERVED;
}
+ if(candev->hwspecops->done_hw_data != NULL)
+ candev->hwspecops->done_hw_data(candev);
+
can_checked_free(candev->hwspecops);
candev->hwspecops=NULL;
}
int i;
struct candevice_t *candev;
- for(i=0; i<canhw->nr_boards; i++){
+ for(i=0; i<MAX_HW_CARDS; i++){
if((candev=canhw->candevice[i])==NULL)
continue;
candevice_done(candev);