From: Luis R. Rodriguez Date: Wed, 11 Apr 2012 01:45:25 +0000 (-0700) Subject: compat: add ndo_do_ioctl() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=78b895ca501b9a70bccccc505b9b39e080de1503;p=openwrt%2Fstaging%2Fblogic.git compat: add ndo_do_ioctl() 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 --- diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 0892e7debe2d..48b62e8a3912 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -226,6 +226,16 @@ struct net_device_ops { #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); @@ -340,14 +350,27 @@ extern int init_dummy_netdev(struct net_device *dev); 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)