]> rtime.felk.cvut.cz Git - lincan.git/commitdiff
Minor repairs in sources
authorJan Kriz <krizj1@fel.cvut.cz>
Sat, 19 Jul 2008 03:59:24 +0000 (05:59 +0200)
committerppisa <pisa@cmp.felk.cvut.cz>
Sat, 19 Jul 2008 03:59:00 +0000 (05:59 +0200)
lincan/include/kthread.h
lincan/include/usbcan.h
lincan/src/Makefile.omk
lincan/src/kthread.c
lincan/src/main.c
lincan/src/usbcan.c

index 1450f81f62979fcf4985a267bf45f5f86116f2bc..559bdd131f58c828333939f736aa685ab8332d75 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _KTHREAD_H
 #define _KTHREAD_H
-#include <linux/config.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+       #include <linux/config.h>
+#endif
 #include <linux/version.h>
 
 #include <linux/kernel.h>
@@ -9,7 +11,7 @@
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40))
   #include <linux/tqueue.h>
   #define tasklet_struct tq_struct
-#else
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
   #include <linux/devfs_fs_kernel.h>
 #endif
 
index 80566cdd8faefe97e74ccc727b030a0e83270fff..df321747911a1cd5c0233b980b6c367501a9db4e 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/usb.h>
 #include <linux/mutex.h>
 
+#include "../include/kthread.h"
+
 /* our private defines. if this grows any larger, use your own .h file */
 #define MAX_TRANSFER           (PAGE_SIZE - 512)
 /* MAX_TRANSFER is chosen so that the VM is not stressed by
@@ -61,13 +63,11 @@ int usbcan_send_msg(struct canchip_t *chip, struct msgobj_t *obj,
 int usbcan_fill_chipspecops(struct canchip_t *chip);
 int usbcan_irq_handler(int irq, struct canchip_t *chip);
 
-void usbcan_read_kthread(kthread_t *kthread);
-int usbcan_chip_queue_status(struct canchip_t *chip);
-
 int usbcan_init(void);
 void usbcan_exit(void);
-static int usbcan_probe(struct usb_interface *interface, const struct usb_device_id *id);
-static void usbcan_disconnect(struct usb_interface *interface);
+
+void usbcan_read_kthread(kthread_t *kthread);
+int usbcan_chip_queue_status(struct canchip_t *chip);
 
 #ifdef CONFIG_OC_LINCAN_DETAILED_ERRORS
 
@@ -168,21 +168,8 @@ struct usbcan_usb {
 #define USBCAN_VENDOR_CHECK_TX_STAT    (4)
 #define USBCAN_VENDOR_START_CHIP       (5)
 #define USBCAN_VENDOR_STOP_CHIP        (6)
-
-/* table of devices that work with this driver */
-static struct usb_device_id usbcan_table [] = {
-       { USB_DEVICE(USBCAN_VENDOR_ID, USBCAN_PRODUCT_ID) },
-       { }                                     /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, usbcan_table);
-
-static struct usb_driver usbcan_driver = {
-       .name =         "usbcan",
-       .id_table = usbcan_table,
-       .probe =        usbcan_probe,
-       .disconnect =   usbcan_disconnect,
-};
-
+#define USBCAN_VENDOR_EXT_MASK_SET     (7)
+#define USBCAN_VENDOR_EXT_MASK_STATUS  (8)
 
 
 #endif /*USBCAN_H*/
index c81f1e14ebff70923204c8be95ffab4fe0c2ee50..fd53820dd67e9201e1111334d7eecc07ff939b31 100644 (file)
@@ -33,6 +33,10 @@ ifeq ($(CONFIG_OC_LINCAN_CARD_ipci165),y)
 lincan_cards_SOURCES += ipci165_fw.c kthread.c
 endif
 
+ifeq ($(CONFIG_OC_LINCAN_CARD_usbcan),y)
+lincan_cards_SOURCES += kthread.c
+endif
+
 ifneq ($(filter hms30c7202_can ns_dev_can,$(lincan_cards_SELECTED)),)
 $(warning Not finished C_CAN support requested)
 lincan_cards_SOURCES += c_can.c c_can_irq.c
index d2531b961e6325785297f7fa26f0c6f373255518..1dfd253d0e3fd492c03c4495b699680d82435838 100644 (file)
@@ -1,5 +1,7 @@
-#include <linux/config.h>
 #include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
+       #include <linux/config.h>
+#endif
 
 #if defined(MODVERSIONS)
 #include <linux/modversions.h>
@@ -9,7 +11,7 @@
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,40))
   #include <linux/tqueue.h>
-#else
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
   #include <linux/devfs_fs_kernel.h>
 #endif
 
@@ -99,7 +101,7 @@ void stop_kthread(kthread_t *kthread)
     init_MUTEX_LOCKED(&kthread->startstop_sem);
 
     /* We need to do a memory barrier here to be sure that
-       the flags are visible on all CPUs. 
+       the flags are visible on all CPUs.
     */
     mb();
 
@@ -107,7 +109,7 @@ void stop_kthread(kthread_t *kthread)
     kthread->terminate = 1;
 
     /* We need to do a memory barrier here to be sure that
-       the flags are visible on all CPUs. 
+       the flags are visible on all CPUs.
     */
     mb();
     kill_proc(kthread->thread->pid, SIGKILL, 1);
index fad1b6d495024d11aa27e2d360d7a25a3b13c434..1574169c3ffd161d9543e1a709d542c42baa32a8 100644 (file)
@@ -74,7 +74,7 @@
 #include "../include/can_iortl.h"
 #endif /*CAN_WITH_RTL*/
 
-#if defined(CONFIG_OC_LINCAN_CARD_ul_usb1)
+#if defined(CONFIG_OC_LINCAN_CARD_usbcan)
        #include "../include/usbcan.h"
 #endif
 
index cb1c9b0b2d285433fefec52715c629ca03ccdf5f..1f9c926687b4e0384a597a7f4ca0b2c3d3fd7db7 100644 (file)
@@ -5,7 +5,6 @@
  * Version lincan-0.3  17 Jul 2008
  */
 
-#include "../include/kthread.h"
 #include "../include/can.h"
 #include "../include/can_sysdep.h"
 #include "../include/main.h"
 #include "../include/setup.h"
 #include "../include/usbcan.h"
 
+static int usbcan_probe(struct usb_interface *interface, const struct usb_device_id *id);
+static void usbcan_disconnect(struct usb_interface *interface);
+
+/* table of devices that work with this driver */
+static struct usb_device_id usbcan_table [] = {
+       { USB_DEVICE(USBCAN_VENDOR_ID, USBCAN_PRODUCT_ID) },
+       { }                                     /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, usbcan_table);
+
+static struct usb_driver usbcan_driver = {
+       .name =         "usbcan",
+       .id_table = usbcan_table,
+       .probe =        usbcan_probe,
+       .disconnect =   usbcan_disconnect,
+};
+
 /**
  * usbcan_request_io: - reserve io or memory range for can board
  * @candev: pointer to candevice/board which asks for io. Field @io_addr
@@ -253,9 +269,9 @@ int usbcan_extended_mask(struct canchip_t *chip, unsigned long code, unsigned  l
        int retval;
        struct usbcan_usb *dev=(struct usbcan_usb*)chip->hostdevice->sysdevptr.anydev;
 
-       struct usbcan_mask_t mask={
-               .code=code;
-               .mask=mask;
+       struct usbcan_mask_t usbmask = {
+               .code=code,
+               .mask=mask,
        };
 
        retval=usb_control_msg(dev->udev,
@@ -263,7 +279,7 @@ int usbcan_extended_mask(struct canchip_t *chip, unsigned long code, unsigned  l
                USBCAN_VENDOR_EXT_MASK_SET,
                USB_TYPE_VENDOR,
                0, chip->chip_idx,
-               &mask, sizeof(usbcan_mask_t),
+               &usbmask, sizeof(struct usbcan_mask_t),
                10000);
        if (retval<0)
                return -ENODEV;
@@ -320,7 +336,7 @@ int usbcan_baud_rate(struct canchip_t *chip, int rate, int clock, int sjw,
                USBCAN_VENDOR_BAUD_RATE_SET,
                USB_TYPE_VENDOR,
                0, chip->chip_idx,
-               &baud, sizeof(can_baudparams_t),
+               &baud, sizeof(struct can_baudparams_t),
                10000);
        if (retval<0)
                return -ENODEV;
@@ -430,12 +446,12 @@ int usbcan_send_msg(struct canchip_t *chip, struct msgobj_t *obj,
                                                        struct canmsg_t *msg)
 {
        struct usbcan_usb *dev=(struct usbcan_usb*)chip->hostdevice->sysdevptr.anydev;
-       int len;
+       int len,retval;
 
        set_bit(USBCAN_TX_PENDING,&dev->flags);
        retval=usb_bulk_msg(dev->udev,
                        usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
-                       &dev->tx_msg, sizeof(usbcan_canmsg_t),
+                       &dev->tx_msg, sizeof(struct usbcan_canmsg_t),
                        &len,10000);
        clear_bit(USBCAN_TX_PENDING,&dev->flags);
        if (retval){
@@ -1003,7 +1019,7 @@ void usbcan_read_kthread(kthread_t *kthread)
        dev->rcv->dev = dev->udev;
        usb_fill_bulk_urb(dev->rcv, dev->udev,
                         usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr),
-                        &dev->rcv_msg, sizeof(usbcan_canmsg_t),
+                        &dev->rcv_msg, sizeof(struct usbcan_canmsg_t),
                         usbcan_rcv, dev);
 
   /* an endless loop in which we are doing our work */
@@ -1016,9 +1032,9 @@ void usbcan_read_kthread(kthread_t *kthread)
                }
                /* fall asleep */
                wait_event_interruptible(kthread->queue,
-                       test_bit(USBCAN_CHIP_DATA_READ,&chip_data->flags)
-                       || test_bit(USBCAN_CHIP_TERMINATE,&chip_data->flags)
-                       || test_bit(USBCAN_CHIP_ERROR,&chip_data->flags)
+                       test_bit(USBCAN_DATA_READ,&dev->flags)
+                       || test_bit(USBCAN_TERMINATE,&dev->flags)
+                       || test_bit(USBCAN_ERROR,&dev->flags)
                );
 
                /* We need to do a memory barrier here to be sure that
@@ -1032,18 +1048,18 @@ void usbcan_read_kthread(kthread_t *kthread)
                        break;
                }
 
-               if (test_bit(USBCAN_CHIP_ERROR,&chip_data->flags)){
+               if (test_bit(USBCAN_ERROR,&dev->flags)){
                        CANMSG("URB error %d\n",retval);
                        break;
                }
 
                { /* Normal work to do */
-                       if (test_bit(USBCAN_CHIP_DATA_READ,&chip_data->flags)){
+                       if (test_bit(USBCAN_DATA_READ,&dev->flags)){
                                int i, len;
-                               clear_bit(USBCAN_CHIP_DATA_READ,&chip_data->flags);
+                               clear_bit(USBCAN_DATA_READ,&dev->flags);
 
                                if ((dev->candev->chip[dev->rcv_msg.chip_id])&&
-                                       (dev->candev->chip[dev->rcv_msg.chip_id].flags & CHIP_CONFIGURED)){
+                                       (dev->candev->chip[dev->rcv_msg.chip_id]->flags & CHIP_CONFIGURED)){
 
                                        obj=dev->candev->chip[dev->rcv_msg.chip_id]->msgobj[0];
                                        if (dev->rcv_msg.flags & MSG_EXT) {