add doit.sh
[openwrt/staging/blogic.git] / patches / 0073-netdevice-mtu-range.cocci
1 @initialize:python@
2 @@
3
4 first_ops = 0
5
6 @both@
7 expression ndevexp;
8 constant e1, e2;
9 identifier func;
10 position p;
11 @@
12 func(...) {
13 <+...
14 ndevexp->min_mtu = e1;
15 ndevexp->max_mtu@p = e2;
16 ...+>
17 }
18
19 @@
20 expression ndevexp;
21 constant MAX;
22 identifier func;
23 position p != both.p;
24 @@
25 func(...) {
26 <+...
27 + ndevexp->min_mtu = 0;
28 ndevexp->max_mtu@p = MAX;
29 ...+>
30 }
31
32 @r@
33 identifier OPS;
34 position p;
35 @@
36
37 struct net_device_ops OPS@p = { ... };
38
39 @script:python depends on r@
40 @@
41
42 first_ops = 0
43
44 @script:python@
45 p << r.p;
46 @@
47
48 ln = int(p[0].line)
49 if first_ops == 0 or ln < first_ops:
50 first_ops = ln
51
52 @script:python@
53 p << r.p;
54 @@
55
56 ln = int(p[0].line)
57 if not(first_ops == ln):
58 cocci.include_match(False)
59
60 @r1 exists@
61 expression ndevexp;
62 constant e1, e2;
63 identifier func;
64 @@
65 func(...) {
66 <+...
67 ndevexp->min_mtu = e1;
68 ndevexp->max_mtu = e2;
69 ...+>
70 }
71
72 @r2@
73 constant r1.e1,r1.e2;
74 identifier r.OPS;
75 @@
76 +#if LINUX_VERSION_IS_LESS(4,10,0)
77 + static int __change_mtu(struct net_device *ndev, int new_mtu)
78 + {
79 + if (new_mtu < e1 || new_mtu > e2)
80 + return -EINVAL;
81 + ndev->mtu = new_mtu;
82 + return 0;
83 + }
84 +#endif
85 +
86 struct net_device_ops OPS = {
87 ...
88 };
89
90 @depends on r2@
91 identifier OPS;
92 @@
93
94 struct net_device_ops OPS = {
95 +#if LINUX_VERSION_IS_LESS(4,10,0)
96 + .ndo_change_mtu = __change_mtu,
97 +#endif
98 ...
99 };
100