+ return;
+ }
+
+ /* Reconfigure ELM327 step by step as indicated by elm->cmds_todo */
+ if (test_bit(TODO_INIT, &elm->cmds_todo)) {
+ strcpy(local_txbuf, *elm->next_init_cmd);
+
+ elm->next_init_cmd++;
+ if (!(*elm->next_init_cmd)) {
+ clear_bit(TODO_INIT, &elm->cmds_todo);
+ netdev_info(elm->dev, "Initialization finished.\n");
+ }
+
+ } else if (test_and_clear_bit(TODO_SILENT_MONITOR, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATCSM%i\r",
+ !(!(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)));
+
+ } else if (test_and_clear_bit(TODO_RESPONSES, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATR%i\r",
+ !(elm->can.ctrlmode & CAN_CTRLMODE_LISTENONLY));
+
+ } else if (test_and_clear_bit(TODO_CAN_CONFIG, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATPC\r");
+ set_bit(TODO_CAN_CONFIG_PART2, &elm->cmds_todo);
+
+ } else if (test_and_clear_bit(TODO_CAN_CONFIG_PART2, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATPB%04X\r",
+ elm->can_config);
+
+ } else if (test_and_clear_bit(TODO_CANID_29BIT_HIGH, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATCP%02X\r",
+ (frame->can_id & CAN_EFF_MASK) >> 24);
+
+ } else if (test_and_clear_bit(TODO_CANID_29BIT_LOW, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATSH%06X\r",
+ frame->can_id & CAN_EFF_MASK & ((1 << 24) - 1));
+
+ } else if (test_and_clear_bit(TODO_CANID_11BIT, &elm->cmds_todo)) {
+ sprintf(local_txbuf, "ATSH%03X\r",
+ frame->can_id & CAN_SFF_MASK);
+
+ } else if (test_and_clear_bit(TODO_CAN_DATA, &elm->cmds_todo)) {
+ if (frame->can_id & CAN_RTR_FLAG) {
+ /* Send an RTR frame. Their DLC is fixed.
+ * Some chips don't send them at all.