]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Merge branch 'master' into can-usb1
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 1 Oct 2011 15:43:17 +0000 (17:43 +0200)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Sat, 1 Oct 2011 15:43:17 +0000 (17:43 +0200)
1  2 
lincan/include/can_sysdep.h
lincan/include/main.h
lincan/src/finish.c

index 5ade3411673048d503ae8d7816684c5cc43c66b7,a2a82180431e8523612f7a240bd639132545389b..60c76de28b8d551ba900621c9650937656e41383
@@@ -56,9 -56,6 +56,9 @@@
  #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 */
  
@@@ -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 <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*/
diff --combined lincan/include/main.h
index 22fb92f72e9be6a559dacaf4fc9b7082737ae2ef,5b4e0e0dbb1633aa4c383b80b558c1f28bac047b..d827594f9022db6a12f51663a8f757f2689f3249
@@@ -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 6a69222d9700fd19ce9f867ba324086c86beb494,be30f84ace76c30a532f65e4395425f89ac6ef45..d1f6a871e807d3d9173216737410124871fd8435
@@@ -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; i<canhw->nr_boards; i++){
 +      for(i=0; i<MAX_HW_CARDS; i++){
                if((candev=canhw->candevice[i])==NULL)
                        continue;
                candevice_done(candev);