Improve error handling in case of stray characters
[elmcan.git] / module / elmcan.c
index 9b4ea45d94d8f4fb44b575bbc812a1cd59e1397b..49df7c1600ca993703e97811f3f5227d8822095f 100644 (file)
@@ -396,8 +396,11 @@ static void elm327_parse_error(struct elmcan *elm, int len)
                }
                break;
        default:
-               /* Don't emit an error frame if we're unsure */
-               return;
+               /* Something else has happened.
+                * Maybe garbage on the UART line.
+                * Emit a generic error frame.
+                */
+               break;
        }
 
        elm327_feed_frame_to_netdev(elm, &frame);
@@ -451,7 +454,6 @@ static int elm327_parse_frame(struct elmcan *elm, int len)
                /* The line is likely garbled anyway, so bail.
                 * The main code will restart listening.
                 */
-               elm327_kick_into_cmd_mode(elm);
                return -ENODATA;
        }
 
@@ -1092,8 +1094,6 @@ static const u32 elmcan_bitrate_const[64] = {
 /* Dummy needed to use bitrate_const */
 static int elmcan_do_set_bittiming(struct net_device *netdev)
 {
-       (void)netdev;
-
        return 0;
 }
 
@@ -1267,9 +1267,6 @@ static int __init elmcan_init(void)
 {
        int status;
 
-       pr_info("ELM327 based best effort CAN interface driver\n");
-       pr_info("This device is severely limited as a CAN interface, see documentation.\n");
-
 #if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)
        status = tty_register_ldisc(N_ELMCAN, &elmcan_ldisc);
 #else