]> rtime.felk.cvut.cz Git - linux-lin.git/blobdiff - sllin/sllin.c
sllin: add single-response flag
[linux-lin.git] / sllin / sllin.c
index 2db896fd8e812da8bd1f535862e3ae98e76d4f1a..1febab2e3e48795d0d5a6066d2ab640b6f6b4bca 100644 (file)
@@ -41,7 +41,7 @@
  * Funded by:  Volkswagen Group Research
  */
 
-#define DEBUG                  1 /* Enables pr_debug() printouts */
+//#define DEBUG                        1 /* Enables pr_debug() printouts */
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -1013,6 +1013,7 @@ static int sllin_kwthread(void *ptr)
        struct sched_param schparam = { .sched_priority = 40 };
        int tx_bytes = 0; /* Used for Network statistics */
        unsigned long flags;
+       int mode;
        int lin_id;
        struct sllin_conf_entry *sce;
 
@@ -1083,8 +1084,12 @@ static int sllin_kwthread(void *ptr)
                        if (!test_bit(SLF_MSGEVENT, &sl->flags))
                                break;
 
+                       mode = 0;
                        cf = (struct can_frame *)sl->tx_req_skb->data;
 
+                       if (cf->can_id & LIN_CHECKSUM_EXTENDED)
+                               mode |= SLLIN_STPMSG_CHCKSUM_ENH;
+
                        /* SFF RTR CAN frame -> LIN header */
                        if (cf->can_id & CAN_RTR_FLAG) {
                                struct sllin_conf_entry *sce;
@@ -1094,11 +1099,16 @@ static int sllin_kwthread(void *ptr)
 
                                sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
                                spin_lock_irqsave(&sl->linfr_lock, flags);
+                               if (sce->frame_fl & LIN_CHECKSUM_EXTENDED)
+                                       mode |= SLLIN_STPMSG_CHCKSUM_ENH;
 
                                /* Is there Slave response in linfr_cache to be sent? */
                                if ((sce->frame_fl & LIN_CACHE_RESPONSE)
                                        && (sce->dlc > 0)) {
 
+                                       if (sce->frame_fl & LIN_SINGLE_RESPONSE)
+                                               sce->frame_fl &= ~LIN_CACHE_RESPONSE;
+
                                        netdev_dbg(sl->dev, "Sending LIN response from linfr_cache\n");
 
                                        lin_data = sce->data;
@@ -1114,9 +1124,15 @@ static int sllin_kwthread(void *ptr)
                                spin_unlock_irqrestore(&sl->linfr_lock, flags);
 
                        } else { /* SFF NON-RTR CAN frame -> LIN header + LIN response */
+                               struct sllin_conf_entry *sce;
+
                                netdev_dbg(sl->dev, "%s: NON-RTR SFF CAN frame, ID = %x\n",
                                        __func__, (int)cf->can_id & LIN_ID_MASK);
 
+                               sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
+                               if (sce->frame_fl & LIN_CHECKSUM_EXTENDED)
+                                       mode |= SLLIN_STPMSG_CHCKSUM_ENH;
+
                                lin_data = cf->data;
                                lin_dlc = cf->can_dlc;
                                if (lin_dlc > SLLIN_DATA_MAX)
@@ -1124,7 +1140,7 @@ static int sllin_kwthread(void *ptr)
                                tx_bytes = lin_dlc;
                        }
 
-                       if (sllin_setup_msg(sl, 0, cf->can_id & LIN_ID_MASK,
+                       if (sllin_setup_msg(sl, mode, cf->can_id & LIN_ID_MASK,
                                lin_data, lin_dlc) != -1) {
 
                                sl->id_to_send = true;
@@ -1242,7 +1258,9 @@ slstate_response_wait:
 
                        if ((sce->frame_fl & LIN_CACHE_RESPONSE)
                                        && (sce->dlc > 0)) {
-                               int mode;
+
+                               if (sce->frame_fl & LIN_SINGLE_RESPONSE)
+                                       sce->frame_fl &= ~LIN_CACHE_RESPONSE;
 
                                netdev_dbg(sl->dev, "Sending LIN response from linfr_cache\n");