Get rid of dummy mailbox_read() for rx_offload
authornorly <ny-git@enpas.org>
Thu, 17 Mar 2022 20:23:10 +0000 (21:23 +0100)
committernorly <ny-git@enpas.org>
Thu, 17 Mar 2022 21:09:56 +0000 (22:09 +0100)
Use can_rx_offload_add_manual() instead of can_rx_offload_add_fifo(),
starting with Linux 5.10.

module/elmcan.c

index 9a58655383bc76a92b527d7ca0a7ed6e23eb7fe4..81d21f4861ab243b8617f6fead2cf94dbe5e6f1e 100644 (file)
@@ -755,6 +755,7 @@ static void elm327_parse_rxbuf(struct elmcan *elm)
        }
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
 /* Dummy needed to use can_rx_offload */
 static struct sk_buff *elmcan_mailbox_read(struct can_rx_offload *offload,
                                           unsigned int n, u32 *timestamp,
@@ -764,6 +765,7 @@ static struct sk_buff *elmcan_mailbox_read(struct can_rx_offload *offload,
 
        return ERR_PTR(-ENOBUFS);
 }
+#endif
 
 static int elmcan_netdev_open(struct net_device *dev)
 {
@@ -792,8 +794,12 @@ static int elmcan_netdev_open(struct net_device *dev)
        elm327_init(elm);
        spin_unlock_bh(&elm->lock);
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0)
        elm->offload.mailbox_read = elmcan_mailbox_read;
        err = can_rx_offload_add_fifo(dev, &elm->offload, ELM327_NAPI_WEIGHT);
+#else
+       err = can_rx_offload_add_manual(dev, &elm->offload, ELM327_NAPI_WEIGHT);
+#endif
        if (err) {
                close_candev(dev);
                return err;