From: Pavel Pisa Date: Sat, 1 Oct 2011 15:43:17 +0000 (+0200) Subject: Merge branch 'master' into can-usb1 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/commitdiff_plain/fe719367cdb25978d42261513dd9810c22481960?hp=-c Merge branch 'master' into can-usb1 --- fe719367cdb25978d42261513dd9810c22481960 diff --combined lincan/include/can_sysdep.h index 5ade341,a2a8218..60c76de --- a/lincan/include/can_sysdep.h +++ b/lincan/include/can_sysdep.h @@@ -56,9 -56,6 +56,9 @@@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10)) + #include +#endif #include #include @@@ -222,6 -219,18 +222,18 @@@ #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 */ @@@ -295,20 -304,4 +307,20 @@@ extern can_spinlock_t can_irq_manipulat #endif /*CAN_WITH_RTL*/ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)) + #include + #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*/ diff --combined lincan/include/main.h index 22fb92f,5b4e0e0..d827594 --- a/lincan/include/main.h +++ b/lincan/include/main.h @@@ -113,10 -113,6 +113,10 @@@ struct candevice_t 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 @@@ -185,7 -181,7 +185,7 @@@ struct canchip_t 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; @@@ -325,16 -321,12 +325,17 @@@ struct hwspecops_t 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 + }; /** @@@ -513,6 -505,12 +514,12 @@@ void can_release_io_region(unsigned lon 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); @@@ -546,7 -544,3 +553,7 @@@ void can_filltimestamp(canmsg_tstamp_t #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); diff --combined lincan/src/finish.c index 6a69222,be30f84..d1f6a87 --- a/lincan/src/finish.c +++ b/lincan/src/finish.c @@@ -39,7 -39,7 +39,7 @@@ #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 @@@ -62,11 -62,8 +62,11 @@@ void msgobj_done(struct msgobj_t *obj } 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"); } @@@ -118,10 -115,6 +118,10 @@@ void canchip_done(struct canchip_t *chi } can_checked_free(chip->chipspecops); + + if(~chip->flags & CHIP_KEEP_DATA) + can_checked_free(chip->chip_data); + chip->chip_data = NULL; chip->chipspecops=NULL; } @@@ -146,6 -139,9 +146,9 @@@ void candevice_done(struct candevice_t 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; } @@@ -159,7 -155,7 +162,7 @@@ void canhardware_done(struct canhardwar int i; struct candevice_t *candev; - for(i=0; inr_boards; i++){ + for(i=0; icandevice[i])==NULL) continue; candevice_done(candev);