From 45db188f26ad6031f17c83c1d7cd848117f20592 Mon Sep 17 00:00:00 2001 From: Rostislav Lisovy Date: Wed, 14 Dec 2011 13:33:20 +0100 Subject: [PATCH] sllin: General purpose LIN-related flags and masks moved into separate header file. --- sllin/linux/lin_bus.h | 23 +++++++++++++++++++++++ sllin/sllin.c | 20 +------------------- 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 sllin/linux/lin_bus.h diff --git a/sllin/linux/lin_bus.h b/sllin/linux/lin_bus.h new file mode 100644 index 0000000..e3aaea4 --- /dev/null +++ b/sllin/linux/lin_bus.h @@ -0,0 +1,23 @@ +#ifndef _LIN_BUS_H_ +#define _LIN_BUS_H_ + +#define SLLIN_ID_MASK 0x3f +#define SLLIN_ID_MAX SLLIN_ID_MASK +#define SLLIN_CTRL_FRAME CAN_EFF_FLAG + +#define SLLIN_CANFR_FLAGS_OFFS 6 /* Lower 6 bits in can_id correspond to LIN ID */ +/* Save configuration for particular LIN ID */ +#define SLLIN_LIN_ID_CONF (1 << SLLIN_CANFR_FLAGS_OFFS) +/* Publisher of particular LIN response is SLLIN Master */ +#define SLLIN_SRC_MASTER (1 << (SLLIN_CANFR_FLAGS_OFFS + 1)) +#define SLLIN_SRC_SLAVE (1 << (SLLIN_CANFR_FLAGS_OFFS + 2)) +#define SLLIN_SLAVE_LOCAL (1 << (SLLIN_CANFR_FLAGS_OFFS + 3)) +#define SLLIN_SLAVE_REMOTE (1 << (SLLIN_CANFR_FLAGS_OFFS + 4)) +#define SLLIN_LOC_SLAVE_CACHE (1 << (SLLIN_CANFR_FLAGS_OFFS + 5)) +#define SLLIN_CHECKSUM_EXTENDED (1 << (SLLIN_CANFR_FLAGS_OFFS + 6)) + +#define SLLIN_ERR_RX_TIMEOUT (1 << (SLLIN_CANFR_FLAGS_OFFS + 7)) +#define SLLIN_ERR_CHECKSUM (1 << (SLLIN_CANFR_FLAGS_OFFS + 8)) +//#define SLLIN_ERR_FRAMING (1 << (SLLIN_CANFR_FLAGS_OFFS + 9)) + +#endif /* _LIN_BUS_H_ */ diff --git a/sllin/sllin.c b/sllin/sllin.c index bb42c40..d1821e8 100644 --- a/sllin/sllin.c +++ b/sllin/sllin.c @@ -58,6 +58,7 @@ #include #include #include +#include "linux/lin_bus.h" /* Should be in include/linux/tty.h */ #define N_SLLIN 25 @@ -89,10 +90,6 @@ MODULE_PARM_DESC(maxdev, "Maximum number of sllin interfaces"); #define SLLIN_BUFF_ID 2 #define SLLIN_BUFF_DATA 3 -#define SLLIN_ID_MASK 0x3f -#define SLLIN_ID_MAX SLLIN_ID_MASK -#define SLLIN_CTRL_FRAME CAN_EFF_FLAG - #define SLLIN_SAMPLES_PER_CHAR 10 #define SLLIN_CHARS_TO_TIMEOUT 12 @@ -109,21 +106,6 @@ enum slstate { struct sllin_conf_entry { int dlc; /* Length of data in LIN frame */ -#define SLLIN_CANFR_FLAGS_OFFS 6 /* Lower 6 bits in can_id correspond to LIN ID */ -/* Save configuration for particular LIN ID */ -#define SLLIN_LIN_ID_CONF (1 << SLLIN_CANFR_FLAGS_OFFS) -/* Publisher of particular LIN response is SLLIN Master */ -#define SLLIN_SRC_MASTER (1 << (SLLIN_CANFR_FLAGS_OFFS + 1)) -#define SLLIN_SRC_SLAVE (1 << (SLLIN_CANFR_FLAGS_OFFS + 2)) -#define SLLIN_SLAVE_LOCAL (1 << (SLLIN_CANFR_FLAGS_OFFS + 3)) -#define SLLIN_SLAVE_REMOTE (1 << (SLLIN_CANFR_FLAGS_OFFS + 4)) -#define SLLIN_LOC_SLAVE_CACHE (1 << (SLLIN_CANFR_FLAGS_OFFS + 5)) -#define SLLIN_CHECKSUM_EXTENDED (1 << (SLLIN_CANFR_FLAGS_OFFS + 6)) - -#define SLLIN_ERR_RX_TIMEOUT (1 << (SLLIN_CANFR_FLAGS_OFFS + 7)) -#define SLLIN_ERR_CHECKSUM (1 << (SLLIN_CANFR_FLAGS_OFFS + 8)) -//#define SLLIN_ERR_FRAMING (1 << (SLLIN_CANFR_FLAGS_OFFS + 9)) - canid_t frame_fl; /* LIN frame flags. Passed from userspace as canid_t data type */ u8 data[8]; /* LIN frame data payload */ }; -- 2.39.2