]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/usbcan.c
report detailed CAN messages processing only if CAN_DEBUG is set.
[lincan.git] / lincan / src / usbcan.c
index 42ece6f260314e729b7f1816d77500a9a92c8702..f67f252809bceda5843f31ba628299ec49377780 100644 (file)
 #include "../include/setup.h"
 #include "../include/usbcan.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
+ #include <linux/freezer.h>
+#endif
+
 static int usbcan_probe(struct usb_interface *interface, const struct usb_device_id *id);
 static void usbcan_disconnect(struct usb_interface *interface);
 
@@ -173,12 +177,13 @@ int usbcan_register(struct hwspecops_t *hwspecops)
 
 // static int sja1000_report_error_limit_counter;
 
-static void sja1000_report_error(struct canchip_t *chip,
+static void usbcan_report_error(struct canchip_t *chip,
                                unsigned sr, unsigned ir, unsigned ecc)
 {
        /*TODO : Error reporting from device */
 
-/*     if(sja1000_report_error_limit_counter>=100)
+#if 0
+       if(sja1000_report_error_limit_counter>=100)
                return;
 
        CANMSG("Error: status register: 0x%x irq_register: 0x%02x error: 0x%02x\n",
@@ -211,6 +216,7 @@ static void sja1000_report_error(struct canchip_t *chip,
                      );
        }
 #endif /*CONFIG_OC_LINCAN_DETAILED_ERRORS*/
+#endif
 }
 
 
@@ -519,7 +525,7 @@ int usbcan_chip_queue_status(struct canchip_t *chip)
        10000);
 
        if (retval==1){
-               CANMSG("Chip_queue_status: %d\n",buf[0]);
+               DEBUGMSG("Chip_queue_status: %d\n",buf[0]);
                if(buf[0]==1)
                        return 0;
                if(buf[0]==0)
@@ -690,10 +696,10 @@ int usbcan_config_irqs(struct canchip_t *chip, short irqs)
  */
 void usbcan_kthread_read_handler(struct usbcan_usb *dev, struct msgobj_t *obj){
        int i, j, len, retval;
-       CANMSG("USBCAN RX handler\n");
+       DEBUGMSG("USBCAN RX handler\n");
        for (i=0;i<USBCAN_TOT_RX_URBS;i++){
                if (test_and_clear_bit(USBCAN_MESSAGE_DATA_OK,&dev->rx[i].flags)){
-                       CANMSG("USBCAN Thread has received a message\n");
+                       DEBUGMSG("USBCAN Thread has received a message\n");
                        if ((dev->chip)&&(dev->chip->flags & CHIP_CONFIGURED)){
                                u8 *ptr;
                                struct usbcan_message *mess=&dev->rx[i];
@@ -717,7 +723,7 @@ void usbcan_kthread_read_handler(struct usbcan_usb *dev, struct msgobj_t *obj){
                                CANMSG("Destination chip not found\n");
                }
                if (!test_bit(USBCAN_MESSAGE_URB_PENDING,&dev->rx[i].flags)){
-                       CANMSG("Renewing RX urb\n");
+                       DEBUGMSG("Renewing RX urb\n");
                        retval = usb_submit_urb (dev->rx[i].u, GFP_KERNEL);
                        if (retval<0){
                                CANMSG("%d. URB error %d\n", i, retval);
@@ -741,11 +747,11 @@ void usbcan_kthread_read_handler(struct usbcan_usb *dev, struct msgobj_t *obj){
  */
 void usbcan_kthread_write_handler(struct usbcan_usb *dev, struct msgobj_t *obj){
        int i;
-       CANMSG("USBCAN TX handler\n");
+       DEBUGMSG("USBCAN TX handler\n");
        for (i=0;i<USBCAN_TOT_TX_URBS;i++){
                if (test_and_clear_bit(USBCAN_MESSAGE_DATA_OK,&dev->tx[i].flags)){
                        struct usbcan_message *mess=&dev->tx[i];
-                       CANMSG("USBCAN Message successfully sent\n");
+                       DEBUGMSG("USBCAN Message successfully sent\n");
 
                        if(mess->slot){
                                // Do local transmitted message distribution if enabled
@@ -790,7 +796,7 @@ void usbcan_kthread_write_request_handler(struct usbcan_usb *dev, struct msgobj_
                        u8 *ptr;
                        cmd=canque_test_outslot(obj->qends, &mess->qedge, &mess->slot);
                        if(cmd>=0){
-                               CANMSG("USBCAN Sending a message\n");
+                               DEBUGMSG("USBCAN Sending a message\n");
 
                                can_msgobj_set_fl(obj,TX_PENDING);
                                clear_bit(USBCAN_FREE_TX_URB,&dev->flags);
@@ -866,7 +872,7 @@ int usbcan_wakeup_tx(struct canchip_t *chip, struct msgobj_t *obj)
 {
        struct usbcan_usb *dev=(struct usbcan_usb *)chip->chip_data;
 
-       CANMSG("Trying to send message\n");
+       DEBUGMSG("Trying to send message\n");
        can_preempt_disable();
 
        can_msgobj_set_fl(obj,TX_PENDING);
@@ -1023,15 +1029,15 @@ static void usbcan_callback(struct urb *urb)
        switch (urb->status) {
        case 0:
                /* success */
-               CANMSG("%s > Message OK\n", __FUNCTION__);
+               DEBUGMSG("%s > Message OK\n", __FUNCTION__);
                set_bit(USBCAN_DATA_OK,&mess->dev->flags);
                set_bit(USBCAN_MESSAGE_DATA_OK,&mess->flags);
                if (test_bit(USBCAN_MESSAGE_TYPE_RX,&mess->flags)){
-                       CANMSG("%s > RX flag set\n", __FUNCTION__);
+                       DEBUGMSG("%s > RX flag set\n", __FUNCTION__);
                        set_bit(USBCAN_DATA_RX,&mess->dev->flags);
                }
                if (test_bit(USBCAN_MESSAGE_TYPE_TX,&mess->flags))
-                       CANMSG("%s > TX flag set\n", __FUNCTION__);
+                       DEBUGMSG("%s > TX flag set\n", __FUNCTION__);
                        set_bit(USBCAN_DATA_TX,&mess->dev->flags);
                clear_bit(USBCAN_MESSAGE_URB_PENDING,&mess->flags);
                if (test_bit(USBCAN_THREAD_RUNNING,&mess->dev->flags))
@@ -1160,7 +1166,7 @@ int usbcan_kthread(void *data)
 
                { /* Normal work to do */
                        if (test_and_clear_bit(USBCAN_DATA_OK,&dev->flags)){
-                               CANMSG("USBCAN Succesfull data transfer\n");
+                               DEBUGMSG("USBCAN Succesfull data transfer\n");
 
                                if (test_and_clear_bit(USBCAN_DATA_RX,&dev->flags)){
                                        usbcan_kthread_read_handler(dev, obj);
@@ -1212,7 +1218,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
 
        iface_desc = interface->cur_altsetting;
        if (iface_desc->desc.bNumEndpoints % 2){
-               err("Endpoint count must be even");
+               CANMSG("Endpoint count must be even");
                goto noalloc;
        }
 
@@ -1220,7 +1226,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
 
        usbdevs = (struct usbcan_devs *) can_checked_malloc(sizeof(struct usbcan_devs));
        if (!usbdevs) {
-               err("Out of memory");
+               CANMSG("Out of memory");
                goto error;
        }
        memset(usbdevs, 0, sizeof(struct usbcan_devs));
@@ -1229,7 +1235,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
 
        usbdevs->devs = (struct usbcan_usb **) can_checked_malloc(usbcan_chip_count * sizeof(struct usbcan_usb *));
        if (!usbdevs->devs) {
-               err("Out of memory");
+               CANMSG("Out of memory");
                goto error;
        }
        memset(usbdevs->devs, 0, usbcan_chip_count * sizeof(struct usbcan_usb *));
@@ -1241,7 +1247,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
                /* allocate memory for our device state and initialize it */
                usbdevs->devs[j] = (struct usbcan_usb *) can_checked_malloc(sizeof(struct usbcan_usb));
                if (!usbdevs->devs[j]) {
-                       err("Out of memory");
+                       CANMSG("Out of memory");
                        goto error;
                }
                memset(usbdevs->devs[j], 0, sizeof(struct usbcan_usb));
@@ -1275,7 +1281,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
                                        dev->bulk_in_endpointAddr = endpoint->bEndpointAddress;
                                        dev->bulk_in_buffer = can_checked_malloc(buffer_size);
                                        if (!dev->bulk_in_buffer) {
-                                               err("Could not allocate bulk_in_buffer");
+                                               CANMSG("Could not allocate bulk_in_buffer");
                                                goto error;
                                        }
                                }
@@ -1291,7 +1297,7 @@ static int usbcan_probe(struct usb_interface *interface, const struct usb_device
 
                }
                if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr)) {
-                       err("Could not find all bulk-in and bulk-out endpoints for chip %d",j);
+                       CANMSG("Could not find all bulk-in and bulk-out endpoints for chip %d",j);
                        goto error;
                }
        }