Add package for sllin driver to image
[AGL/meta-agl-demo.git] / recipes-kernel / sllin / files / 0003-Allow-recent-kernels-newer-4.11.x-to-build.patch
1 From fcebb8f510bbb5c681f1f9af4506b4de241837dd Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jan-Simon=20M=C3=B6ller?= <jsmoeller@linuxfoundation.org>
3 Date: Wed, 31 Oct 2018 20:48:20 +0000
4 Subject: [PATCH] Allow recent kernels newer 4.11.x to build
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 API changes enforce porting.
10
11 Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
12 ---
13  sllin/sllin.c | 13 +++++++++++++
14  1 file changed, 13 insertions(+)
15
16 diff --git a/sllin/sllin.c b/sllin/sllin.c
17 index 2969448..7e17127 100644
18 --- a/sllin/sllin.c
19 +++ b/sllin/sllin.c
20 @@ -56,7 +56,12 @@
21  #include <linux/rtnetlink.h>
22  #include <linux/if_arp.h>
23  #include <linux/if_ether.h>
24 +#include <linux/version.h>
25 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
26  #include <linux/sched.h>
27 +#else
28 +#include <uapi/linux/sched/types.h>
29 +#endif
30  #include <linux/delay.h>
31  #include <linux/init.h>
32  #include <linux/can.h>
33 @@ -447,7 +451,9 @@ static int sll_open(struct net_device *dev)
34  static void sll_free_netdev(struct net_device *dev)
35  {
36         int i = dev->base_addr;
37 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,9)
38         free_netdev(dev);
39 +#endif
40         sllin_devs[i] = NULL;
41  }
42  
43 @@ -460,7 +466,12 @@ static const struct net_device_ops sll_netdev_ops = {
44  static void sll_setup(struct net_device *dev)
45  {
46         dev->netdev_ops         = &sll_netdev_ops;
47 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,9)
48         dev->destructor         = sll_free_netdev;
49 +#else
50 +       dev->needs_free_netdev  = true;
51 +        dev->priv_destructor    = sll_free_netdev;
52 +#endif
53  
54         dev->hard_header_len    = 0;
55         dev->addr_len           = 0;
56 @@ -1685,8 +1696,10 @@ static void __exit sllin_exit(void)
57                 sl = netdev_priv(dev);
58                 if (sl->tty) {
59                         netdev_dbg(sl->dev, "tty discipline still running\n");
60 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,9)
61                         /* Intentionally leak the control block. */
62                         dev->destructor = NULL;
63 +#endif
64                 }
65  
66                 unregister_netdev(dev);
67 -- 
68 2.13.7
69