1 diff --git a/sllin/sllin.c b/sllin/sllin.c
2 index 2db896f..2969448 100644
5 @@ -869,7 +869,6 @@ static int sllin_send_tx_buff(struct sllin *sl)
7 remains = sl->tx_lim - sl->tx_cnt;
10 res = tty->ops->write(tty, sl->tx_buff + sl->tx_cnt, remains);
13 @@ -916,10 +915,25 @@ static int sllin_send_break(struct sllin *sl)
14 unsigned long break_baud;
17 + netdev_dbg(sl->dev, "%s()#<BREAK_BY_BAUD> invoke.\n", __func__);
19 + netdev_dbg(sl->dev, "%s() tty == NULL.\n", __func__);
20 + sl->lin_state = SLSTATE_IDLE;
23 + if (tty->ops == NULL) {
24 + netdev_dbg(sl->dev, "%s() tty->ops == NULL.\n", __func__);
25 + sl->lin_state = SLSTATE_IDLE;
28 break_baud = ((sl->lin_baud * 2) / 3);
29 sltty_change_speed(tty, break_baud);
31 - tty->ops->flush_buffer(tty);
32 + if (tty->ops->flush_buffer) {
33 + tty->ops->flush_buffer(tty);
35 + netdev_dbg(sl->dev, "%s() tty->ops->flush_buffer is NULL.\n", __func__);
37 sl->rx_cnt = SLLIN_BUFF_BREAK;
39 sl->rx_expect = SLLIN_BUFF_BREAK + 1;
40 @@ -943,6 +957,17 @@ static int sllin_send_break(struct sllin *sl)
41 unsigned long usleep_range_min;
42 unsigned long usleep_range_max;
44 + netdev_dbg(sl->dev, "%s() invoke.\n", __func__);
46 + netdev_dbg(sl->dev, "%s() tty == NULL.\n", __func__);
47 + sl->lin_state = SLSTATE_IDLE;
50 + if (tty->ops == NULL) {
51 + netdev_dbg(sl->dev, "%s() tty->ops == NULL.\n", __func__);
52 + sl->lin_state = SLSTATE_IDLE;
55 break_baud = ((sl->lin_baud * 2) / 3);
56 sl->rx_cnt = SLLIN_BUFF_BREAK;
57 sl->rx_expect = SLLIN_BUFF_BREAK + 1;
58 @@ -950,21 +975,31 @@ static int sllin_send_break(struct sllin *sl)
60 /* Do the break ourselves; Inspired by
61 http://lxr.linux.no/#linux+v3.1.2/drivers/tty/tty_io.c#L2452 */
62 - retval = tty->ops->break_ctl(tty, -1);
65 + if (tty->ops->break_ctl) {
66 + retval = tty->ops->break_ctl(tty, -1);
70 + netdev_dbg(sl->dev, "%s() tty->ops->break_ctl is NULL.\n", __func__);
74 usleep_range_min = (1000000l * SLLIN_SAMPLES_PER_CHAR) / break_baud;
75 usleep_range_max = usleep_range_min + 50;
76 usleep_range(usleep_range_min, usleep_range_max);
78 - retval = tty->ops->break_ctl(tty, 0);
79 + if(tty->ops->break_ctl) {
80 + retval = tty->ops->break_ctl(tty, 0);
82 usleep_range_min = (1000000l * 1 /* 1 bit */) / break_baud;
83 usleep_range_max = usleep_range_min + 30;
84 usleep_range(usleep_range_min, usleep_range_max);
86 - tty->ops->flush_buffer(tty);
87 + if ( tty->ops->flush_buffer) {
88 + tty->ops->flush_buffer(tty);
90 + netdev_dbg(sl->dev, "%s() tty->ops->flush_buffer is NULL.\n", __func__);
93 sl->tx_cnt = SLLIN_BUFF_SYNC;
95 @@ -1028,6 +1063,12 @@ static int sllin_kwthread(void *ptr)
97 u8 lin_data_buff[SLLIN_DATA_MAX];
100 + pr_err("sllin: sl is NULL\n");
102 + if (sl->dev == NULL) {
103 + pr_err("sllin: sl->dev is NULL\n");
106 if ((sl->lin_state == SLSTATE_IDLE) && sl->lin_master &&
108 @@ -1036,6 +1077,7 @@ static int sllin_kwthread(void *ptr)
112 + netdev_dbg(sl->dev, "sllin_kthread <WAIT_EVENT>\n");
113 wait_event_killable(sl->kwt_wq, kthread_should_stop() ||
114 test_bit(SLF_RXEVENT, &sl->flags) ||
115 test_bit(SLF_TXEVENT, &sl->flags) ||
116 @@ -1046,6 +1088,7 @@ static int sllin_kwthread(void *ptr)
117 (sl->lin_state == SLSTATE_RESPONSE_WAIT))
118 && test_bit(SLF_MSGEVENT, &sl->flags)));
120 + netdev_dbg(sl->dev, "sllin_kthread <WAKEUPED>\n");
121 if (test_and_clear_bit(SLF_RXEVENT, &sl->flags)) {
122 netdev_dbg(sl->dev, "sllin_kthread RXEVENT\n");
124 @@ -1078,21 +1121,25 @@ static int sllin_kwthread(void *ptr)
125 sl->lin_state = SLSTATE_IDLE;
128 + netdev_dbg(sl->dev, "sllin_kthread: lin_state <%08x>\n",sl->lin_state);
129 switch (sl->lin_state) {
131 if (!test_bit(SLF_MSGEVENT, &sl->flags))
134 + if (sl->tx_req_skb == NULL)
135 + netdev_dbg(sl->dev, "sl->tx_req_skb == NULL\n");
136 + if (sl->tx_req_skb->data == NULL)
137 + netdev_dbg(sl->dev, "sl->tx_req_skb->data == NULL\n");
138 cf = (struct can_frame *)sl->tx_req_skb->data;
140 /* SFF RTR CAN frame -> LIN header */
141 if (cf->can_id & CAN_RTR_FLAG) {
142 struct sllin_conf_entry *sce;
144 - netdev_dbg(sl->dev, "%s: RTR SFF CAN frame, ID = %x\n",
145 - __func__, cf->can_id & LIN_ID_MASK);
147 sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
148 + netdev_dbg(sl->dev, "%s: RTR SFF CAN frame, ID = %x dlc=%d\n",
149 + __func__, cf->can_id & LIN_ID_MASK, sce->dlc);
150 spin_lock_irqsave(&sl->linfr_lock, flags);
152 /* Is there Slave response in linfr_cache to be sent? */
153 @@ -1114,8 +1161,8 @@ static int sllin_kwthread(void *ptr)
154 spin_unlock_irqrestore(&sl->linfr_lock, flags);
156 } else { /* SFF NON-RTR CAN frame -> LIN header + LIN response */
157 - netdev_dbg(sl->dev, "%s: NON-RTR SFF CAN frame, ID = %x\n",
158 - __func__, (int)cf->can_id & LIN_ID_MASK);
159 + netdev_dbg(sl->dev, "%s: NON-RTR SFF CAN frame, ID = %x\n dlc=%d",
160 + __func__, (int)cf->can_id & LIN_ID_MASK, cf->can_dlc);
163 lin_dlc = cf->can_dlc;
164 @@ -1140,6 +1187,7 @@ static int sllin_kwthread(void *ptr)
165 hrtimer_start(&sl->rx_timer,
166 ktime_add(ktime_get(), sl->rx_timer_timeout),
168 + netdev_dbg(sl->dev, "sllin_kthread: SLSTATE finish\n");
171 case SLSTATE_BREAK_SENT:
172 @@ -1654,3 +1702,4 @@ static void __exit sllin_exit(void)
174 module_init(sllin_init);
175 module_exit(sllin_exit);