.. | .. |
---|
344 | 344 | } |
---|
345 | 345 | } |
---|
346 | 346 | |
---|
347 | | -static inline void c_can_activate_all_lower_rx_msg_obj(struct net_device *dev, |
---|
348 | | - int iface) |
---|
349 | | -{ |
---|
350 | | - int i; |
---|
351 | | - |
---|
352 | | - for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_MSG_RX_LOW_LAST; i++) |
---|
353 | | - c_can_object_get(dev, iface, i, IF_COMM_CLR_NEWDAT); |
---|
354 | | -} |
---|
355 | | - |
---|
356 | 347 | static int c_can_handle_lost_msg_obj(struct net_device *dev, |
---|
357 | 348 | int iface, int objno, u32 ctrl) |
---|
358 | 349 | { |
---|
.. | .. |
---|
903 | 894 | struct can_berr_counter bec; |
---|
904 | 895 | |
---|
905 | 896 | switch (error_type) { |
---|
| 897 | + case C_CAN_NO_ERROR: |
---|
| 898 | + priv->can.state = CAN_STATE_ERROR_ACTIVE; |
---|
| 899 | + break; |
---|
906 | 900 | case C_CAN_ERROR_WARNING: |
---|
907 | 901 | /* error warning state */ |
---|
908 | 902 | priv->can.can_stats.error_warning++; |
---|
.. | .. |
---|
933 | 927 | ERR_CNT_RP_SHIFT; |
---|
934 | 928 | |
---|
935 | 929 | switch (error_type) { |
---|
| 930 | + case C_CAN_NO_ERROR: |
---|
| 931 | + /* error warning state */ |
---|
| 932 | + cf->can_id |= CAN_ERR_CRTL; |
---|
| 933 | + cf->data[1] = CAN_ERR_CRTL_ACTIVE; |
---|
| 934 | + cf->data[6] = bec.txerr; |
---|
| 935 | + cf->data[7] = bec.rxerr; |
---|
| 936 | + break; |
---|
936 | 937 | case C_CAN_ERROR_WARNING: |
---|
937 | 938 | /* error warning state */ |
---|
938 | 939 | cf->can_id |= CAN_ERR_CRTL; |
---|
.. | .. |
---|
1077 | 1078 | /* handle bus recovery events */ |
---|
1078 | 1079 | if ((!(curr & STATUS_BOFF)) && (last & STATUS_BOFF)) { |
---|
1079 | 1080 | netdev_dbg(dev, "left bus off state\n"); |
---|
1080 | | - priv->can.state = CAN_STATE_ERROR_ACTIVE; |
---|
| 1081 | + work_done += c_can_handle_state_change(dev, C_CAN_ERROR_PASSIVE); |
---|
1081 | 1082 | } |
---|
| 1083 | + |
---|
1082 | 1084 | if ((!(curr & STATUS_EPASS)) && (last & STATUS_EPASS)) { |
---|
1083 | 1085 | netdev_dbg(dev, "left error passive state\n"); |
---|
1084 | | - priv->can.state = CAN_STATE_ERROR_ACTIVE; |
---|
| 1086 | + work_done += c_can_handle_state_change(dev, C_CAN_ERROR_WARNING); |
---|
| 1087 | + } |
---|
| 1088 | + |
---|
| 1089 | + if ((!(curr & STATUS_EWARN)) && (last & STATUS_EWARN)) { |
---|
| 1090 | + netdev_dbg(dev, "left error warning state\n"); |
---|
| 1091 | + work_done += c_can_handle_state_change(dev, C_CAN_NO_ERROR); |
---|
1085 | 1092 | } |
---|
1086 | 1093 | |
---|
1087 | 1094 | /* handle lec errors on the bus */ |
---|
.. | .. |
---|
1276 | 1283 | time_after(time_out, jiffies)) |
---|
1277 | 1284 | cpu_relax(); |
---|
1278 | 1285 | |
---|
1279 | | - if (time_after(jiffies, time_out)) |
---|
1280 | | - return -ETIMEDOUT; |
---|
| 1286 | + if (time_after(jiffies, time_out)) { |
---|
| 1287 | + ret = -ETIMEDOUT; |
---|
| 1288 | + goto err_out; |
---|
| 1289 | + } |
---|
1281 | 1290 | |
---|
1282 | 1291 | ret = c_can_start(dev); |
---|
1283 | | - if (!ret) |
---|
1284 | | - c_can_irq_control(priv, true); |
---|
| 1292 | + if (ret) |
---|
| 1293 | + goto err_out; |
---|
| 1294 | + |
---|
| 1295 | + c_can_irq_control(priv, true); |
---|
| 1296 | + |
---|
| 1297 | + return 0; |
---|
| 1298 | + |
---|
| 1299 | +err_out: |
---|
| 1300 | + c_can_reset_ram(priv, false); |
---|
| 1301 | + c_can_pm_runtime_put_sync(priv); |
---|
1285 | 1302 | |
---|
1286 | 1303 | return ret; |
---|
1287 | 1304 | } |
---|