]> rtime.felk.cvut.cz Git - linux-lin.git/commitdiff
sllin: Flags clean up
authorRostislav Lisovy <lisovy@gmail.com>
Fri, 20 Jul 2012 09:16:43 +0000 (11:16 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Fri, 20 Jul 2012 09:16:43 +0000 (11:16 +0200)
sllin/linux/lin_bus.h
sllin/sllin.c

index 313b851e246b98070edb3b6c9433e013dbb04269..dbd9a783e2c76ea22edd3eea43a41b42638f5f66 100644 (file)
@@ -8,18 +8,14 @@
 #define LIN_DEFAULT_BAUDRATE   19200
 
 #define LIN_CANFR_FLAGS_OFFS   6 /* Lower 6 bits in can_id correspond to LIN ID */
-/* Save configuration for particular LIN ID */
-#define LIN_ID_CONF            (1 <<  LIN_CANFR_FLAGS_OFFS)
-/* Publisher of particular LIN response is SLLIN Master */
-#define LIN_SRC_MASTER         (1 << (LIN_CANFR_FLAGS_OFFS + 1))
-#define LIN_SRC_SLAVE          (1 << (LIN_CANFR_FLAGS_OFFS + 2))
-#define LIN_SLAVE_LOCAL                (1 << (LIN_CANFR_FLAGS_OFFS + 3))
-#define LIN_SLAVE_REMOTE       (1 << (LIN_CANFR_FLAGS_OFFS + 4))
-#define LIN_LOC_SLAVE_CACHE    (1 << (LIN_CANFR_FLAGS_OFFS + 5))
-#define LIN_CHECKSUM_EXTENDED  (1 << (LIN_CANFR_FLAGS_OFFS + 6))
 
-#define LIN_ERR_RX_TIMEOUT     (1 << (LIN_CANFR_FLAGS_OFFS + 7))
-#define LIN_ERR_CHECKSUM       (1 << (LIN_CANFR_FLAGS_OFFS + 8))
-#define LIN_ERR_FRAMING                (1 << (LIN_CANFR_FLAGS_OFFS + 9))
+#define LIN_CACHE_RESPONSE     (1 << (LIN_CANFR_FLAGS_OFFS))
+#define LIN_CHECKSUM_EXTENDED  (1 << (LIN_CANFR_FLAGS_OFFS + 1))
+
+
+/* Error flags */
+#define LIN_ERR_RX_TIMEOUT     (1 << (LIN_CANFR_FLAGS_OFFS + 8))
+#define LIN_ERR_CHECKSUM       (1 << (LIN_CANFR_FLAGS_OFFS + 9))
+#define LIN_ERR_FRAMING                (1 << (LIN_CANFR_FLAGS_OFFS + 10))
 
 #endif /* _LIN_BUS_H_ */
index 601979a2213232c5beae2081126b2ef17ca3b591..dc308845e23f4e3e5fffe0782a9933aa875edec6 100644 (file)
@@ -550,7 +550,7 @@ static void sllin_slave_receive_buf(struct tty_struct *tty,
 
                        spin_lock_irqsave(&sl->linfr_lock, flags);
                        /* Is the length of data set in frame cache? */
-                       if (sce->frame_fl & LIN_LOC_SLAVE_CACHE) {
+                       if (sce->frame_fl & LIN_CACHE_RESPONSE) {
                                sl->rx_expect += sce->dlc;
                                sl->rx_len_unknown = false;
                        } else {
@@ -641,7 +641,7 @@ static int sllin_configure_frame_cache(struct sllin *sl, struct can_frame *cf)
        unsigned long flags;
        struct sllin_conf_entry *sce;
 
-       if (!(cf->can_id & LIN_ID_CONF))
+       if (!(cf->can_id & LIN_CTRL_FRAME))
                return -1;
 
        sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
@@ -715,8 +715,9 @@ int sllin_setup_msg(struct sllin *sl, int mode, int id,
        if ((data != NULL) && len) {
                sl->tx_lim += len;
                memcpy(sl->tx_buff + SLLIN_BUFF_DATA, data, len);
-               sl->tx_buff[sl->tx_lim++] = sllin_checksum(sl->tx_buff,
+               sl->tx_buff[sl->tx_lim] = sllin_checksum(sl->tx_buff,
                                sl->tx_lim, mode & SLLIN_STPMSG_CHCKSUM_ENH);
+               sl->tx_lim++;
        }
        if (len != 0)
                sl->rx_lim = SLLIN_BUFF_DATA + len + 1;
@@ -1003,7 +1004,7 @@ int sllin_kwthread(void *ptr)
                                spin_lock_irqsave(&sl->linfr_lock, flags);
 
                                /* Is there Slave response in linfr_cache to be sent? */
-                               if ((sce->frame_fl & LIN_LOC_SLAVE_CACHE)
+                               if ((sce->frame_fl & LIN_CACHE_RESPONSE)
                                        && (sce->dlc > 0)) {
 
                                        pr_debug("sllin: Sending LIN response from linfr_cache\n");