aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/ethtool.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-07-31 17:00:29 -0400
committerDavid S. Miller <davem@davemloft.net>2007-07-31 17:00:29 -0400
commit313674afa8fdced2fe79f50f38e1c387b63d8790 (patch)
tree40b14cab2f48af45615dacf35c93a268c42b7f9a /net/core/ethtool.c
parent61a44b9c4b20d40c41fd1b70a4ceb13b75ea79a4 (diff)
[NET]: ethtool_perm_addr only has one implementation
All drivers implement ethtool get_perm_addr the same way -- by calling the generic function. So we can inline the generic function into the caller and avoid going through the drivers. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/ethtool.c')
-rw-r--r--net/core/ethtool.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 2bf565e8d0b3..2ab0a60046a5 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -95,18 +95,6 @@ int ethtool_op_set_tso(struct net_device *dev, u32 data)
95 return 0; 95 return 0;
96} 96}
97 97
98int ethtool_op_get_perm_addr(struct net_device *dev, struct ethtool_perm_addr *addr, u8 *data)
99{
100 unsigned char len = dev->addr_len;
101 if ( addr->size < len )
102 return -ETOOSMALL;
103
104 addr->size = len;
105 memcpy(data, dev->perm_addr, len);
106 return 0;
107}
108
109
110u32 ethtool_op_get_ufo(struct net_device *dev) 98u32 ethtool_op_get_ufo(struct net_device *dev)
111{ 99{
112 return (dev->features & NETIF_F_UFO) != 0; 100 return (dev->features & NETIF_F_UFO) != 0;
@@ -779,34 +767,20 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
779static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr) 767static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
780{ 768{
781 struct ethtool_perm_addr epaddr; 769 struct ethtool_perm_addr epaddr;
782 u8 *data;
783 int ret;
784
785 if (!dev->ethtool_ops->get_perm_addr)
786 return -EOPNOTSUPP;
787 770
788 if (copy_from_user(&epaddr,useraddr,sizeof(epaddr))) 771 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
789 return -EFAULT; 772 return -EFAULT;
790 773
791 data = kmalloc(epaddr.size, GFP_USER); 774 if (epaddr.size < dev->addr_len)
792 if (!data) 775 return -ETOOSMALL;
793 return -ENOMEM; 776 epaddr.size = dev->addr_len;
794
795 ret = dev->ethtool_ops->get_perm_addr(dev,&epaddr,data);
796 if (ret)
797 return ret;
798 777
799 ret = -EFAULT;
800 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr))) 778 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
801 goto out; 779 return -EFAULT;
802 useraddr += sizeof(epaddr); 780 useraddr += sizeof(epaddr);
803 if (copy_to_user(useraddr, data, epaddr.size)) 781 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
804 goto out; 782 return -EFAULT;
805 ret = 0; 783 return 0;
806
807 out:
808 kfree(data);
809 return ret;
810} 784}
811 785
812/* The main entry point in this file. Called from net/core/dev.c */ 786/* The main entry point in this file. Called from net/core/dev.c */
@@ -976,7 +950,6 @@ int dev_ethtool(struct ifreq *ifr)
976 950
977EXPORT_SYMBOL(dev_ethtool); 951EXPORT_SYMBOL(dev_ethtool);
978EXPORT_SYMBOL(ethtool_op_get_link); 952EXPORT_SYMBOL(ethtool_op_get_link);
979EXPORT_SYMBOL_GPL(ethtool_op_get_perm_addr);
980EXPORT_SYMBOL(ethtool_op_get_sg); 953EXPORT_SYMBOL(ethtool_op_get_sg);
981EXPORT_SYMBOL(ethtool_op_get_tso); 954EXPORT_SYMBOL(ethtool_op_get_tso);
982EXPORT_SYMBOL(ethtool_op_get_tx_csum); 955EXPORT_SYMBOL(ethtool_op_get_tx_csum);