+/**
+ * sllin_report_error() -- Report an error by sending CAN frame
+ * with particular error flag set in can_id
+ *
+ * @sl:
+ * @err: Error flag to be sent.
+ */
+void sllin_report_error(struct sllin *sl, int err)
+{
+ switch (err) {
+ case LIN_ERR_CHECKSUM:
+ sl->dev->stats.rx_crc_errors++;
+ break;
+
+ case LIN_ERR_RX_TIMEOUT:
+ sl->dev->stats.rx_errors++;
+ break;
+
+ case LIN_ERR_FRAMING:
+ sl->dev->stats.rx_frame_errors++;
+ break;
+ }
+
+ sllin_send_canfr(sl, 0 | CAN_EFF_FLAG |
+ (err & ~LIN_ID_MASK), NULL, 0);
+}
+
+/**
+ * sllin_configure_frame_cache() -- Configure particular entry in linfr_cache
+ *
+ * @sl:
+ * @cf: Pointer to CAN frame sent to this driver
+ * holding configuration information
+ */
+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_CTRL_FRAME))
+ return -1;
+
+ sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
+ netdev_dbg(sl->dev, "Setting frame cache with EFF CAN frame. LIN ID = %d\n",
+ cf->can_id & LIN_ID_MASK);
+
+ spin_lock_irqsave(&sl->linfr_lock, flags);
+
+ sce->dlc = cf->can_dlc;
+ if (sce->dlc > SLLIN_DATA_MAX)
+ sce->dlc = SLLIN_DATA_MAX;
+
+ sce->frame_fl = (cf->can_id & ~LIN_ID_MASK) & CAN_EFF_MASK;
+ memcpy(sce->data, cf->data, cf->can_dlc);
+
+ spin_unlock_irqrestore(&sl->linfr_lock, flags);
+
+ return 0;
+}
+
+/**
+ * sllin_checksum() -- Count checksum for particular data
+ *
+ * @data: Pointer to the buffer containing whole LIN
+ * frame (i.e. including break and sync bytes).
+ * @length: Length of the buffer.
+ * @enhanced_fl: Flag determining whether Enhanced or Classic
+ * checksum should be counted.
+ */
+static inline unsigned sllin_checksum(unsigned char *data, int length, int enhanced_fl)
+{
+ unsigned csum = 0;
+ int i;
+
+ if (enhanced_fl)
+ i = SLLIN_BUFF_ID;
+ else
+ i = SLLIN_BUFF_DATA;
+
+ for (; i < length; i++) {
+ csum += data[i];
+ if (csum > 255)
+ csum -= 255;
+ }
+
+ return ~csum & 0xff;
+}
+
+#define SLLIN_STPMSG_RESPONLY (1) /* Message will be LIN Response only */
+#define SLLIN_STPMSG_CHCKSUM_CLS (1 << 1)
+#define SLLIN_STPMSG_CHCKSUM_ENH (1 << 2)