This helps reduce the delta on backporting calls of the
netdev's ioctl callback. Instead of ifdef'ing on where
the ioctl callback lies in different kernels we take
care of that for all kernels.
This lets us for example change this backport:
@@ -925,8 +954,13 @@ static int wireless_process_ioctl(struct
return private(dev, iwr, cmd, info, handler);
}
/* Old driver API : call driver ioctl handler */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29))
if (dev->netdev_ops->ndo_do_ioctl)
return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
+#else
+ if (dev->do_ioctl)
+ return dev->do_ioctl(dev, ifr, cmd);
+#endif
return -EOPNOTSUPP;
}
To this:
--- a/net/wireless/wext-core.c
+++ b/net/wireless/wext-core.c
@@ -925,9 +925,7 @@ static int wireless_process_ioctl(struct
return private(dev, iwr, cmd, info, handler);
}
/* Old driver API : call driver ioctl handler */
- if (dev->netdev_ops->ndo_do_ioctl)
- return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
- return -EOPNOTSUPP;
+ return ndo_do_ioctl(dev, ifr, cmd);
}
/* If command is `set a parameter', or `get the encoding parameters',
This shows more deletions than additions. This is what we want.
If we add ndo_do_ioctl() upstream then this would require 0 delta!
Trying kernel 3.4.0-030400rc1-generic [OK]
Trying kernel 3.3.0-030300rc2-generic [OK]
Trying kernel 3.2.2-030202-generic [OK]
Trying kernel 3.1.10-030110-generic [OK]
Trying kernel 3.0.18-030018-generic [OK]
Trying kernel 2.6.39-
02063904-generic [OK]
Trying kernel 2.6.38-
02063808-generic [OK]
Trying kernel 2.6.37-
02063706-generic [OK]
Trying kernel 2.6.36-
02063604-generic [OK]
Trying kernel 2.6.35-
02063512-generic [OK]
Trying kernel 2.6.34-
02063410-generic [OK]
Trying kernel 2.6.33-
02063305-generic [OK]
Trying kernel 2.6.32-
02063255-generic [OK]
Trying kernel 2.6.31-
02063113-generic [OK]
Trying kernel 2.6.30-
02063010-generic [OK]
Trying kernel 2.6.29-
02062906-generic [OK]
Trying kernel 2.6.28-
02062810-generic [OK]
Trying kernel 2.6.27-020627-generic [OK]
Trying kernel 2.6.26-020626-generic [OK]
Trying kernel 2.6.25-020625-generic [OK]
Trying kernel 2.6.24-020624-generic [OK]
Signed-off-by: Luis R. Rodriguez <mcgrof@frijolero.org>
#endif
};
+static inline int ndo_do_ioctl(struct net_device *dev,
+ struct ifreq *ifr,
+ int cmd)
+{
+ if (dev->do_ioctl)
+ return dev->do_ioctl(dev, ifr, cmd);
+ return -EOPNOTSUPP;
+}
+
+
void netdev_attach_ops(struct net_device *dev,
const struct net_device_ops *ops);
return fn(&pdev->dev); \
}
-#else
+#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */
+/* Kernels >= 2.6.29 follows */
+
+/* XXX: this can probably just go upstream ! */
static inline void netdev_attach_ops(struct net_device *dev,
const struct net_device_ops *ops)
{
dev->netdev_ops = ops;
}
+/* XXX: this can probably just go upstream! */
+static inline int ndo_do_ioctl(struct net_device *dev,
+ struct ifreq *ifr,
+ int cmd)
+{
+ if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl)
+ return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
+ return -EOPNOTSUPP;
+}
+
#define compat_pci_suspend(fn)
#define compat_pci_resume(fn)