diff mbox

[2/3] ethtool: Add common functions for get and set settings

Message ID 1465798076-176393-3-git-send-email-lidongpo@hisilicon.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Dongpo Li June 13, 2016, 6:07 a.m. UTC
Currently, most drivers only support get and set PHY settings
by PHY ethtool API. For those drivers, it's better to
supply common functions for get_settings and set_settings.
This patch adds common functions implementation.

Reviewed-by: Jiancheng Xue <xuejiancheng@hisilicon.com>
Signed-off-by: Dongpo Li <lidongpo@hisilicon.com>
---
 include/linux/ethtool.h |  2 ++
 net/core/ethtool.c      | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)

Comments

kernel test robot June 13, 2016, 7:36 a.m. UTC | #1
Hi,

[auto build test ERROR on net/master]
[also build test ERROR on v4.7-rc3 next-20160609]
[cannot apply to net-next/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dongpo-Li/Add-Hisilicon-MDIO-bus-driver-and-FEMAC-driver/20160613-141459
config: i386-randconfig-i0-201624 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `ethtool_op_get_settings':
>> (.text+0x18f07): undefined reference to `phy_ethtool_gset'
   net/built-in.o: In function `ethtool_op_set_settings':
>> (.text+0x18f40): undefined reference to `phy_ethtool_sset'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 13, 2016, 8:11 a.m. UTC | #2
Hi,

[auto build test ERROR on net/master]
[also build test ERROR on v4.7-rc3 next-20160609]
[cannot apply to net-next/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dongpo-Li/Add-Hisilicon-MDIO-bus-driver-and-FEMAC-driver/20160613-141459
config: sh-sh7785lcr_32bit_defconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `ethtool_op_get_settings':
>> net/core/ethtool.c:56: undefined reference to `phy_ethtool_gset'
   net/built-in.o: In function `ethtool_op_set_settings':
>> net/core/ethtool.c:68: undefined reference to `phy_ethtool_sset'

vim +56 net/core/ethtool.c

    50	}
    51	EXPORT_SYMBOL(ethtool_op_get_ts_info);
    52	
    53	int ethtool_op_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
    54	{
    55		if (!dev->phydev)
  > 56			return -ENODEV;
    57	
    58		return phy_ethtool_gset(dev->phydev, cmd);
    59	}
    60	EXPORT_SYMBOL(ethtool_op_get_settings);
    61	
    62	int ethtool_op_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
    63	{
    64		if (!capable(CAP_NET_ADMIN))
    65			return -EPERM;
    66	
    67		if (!dev->phydev)
  > 68			return -ENODEV;
    69	
    70		return phy_ethtool_sset(dev->phydev, cmd);
    71	}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 13, 2016, 8:38 a.m. UTC | #3
Hi,

[auto build test ERROR on net/master]
[also build test ERROR on v4.7-rc3 next-20160609]
[cannot apply to net-next/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Dongpo-Li/Add-Hisilicon-MDIO-bus-driver-and-FEMAC-driver/20160613-141459
config: arm-magician_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   net/built-in.o: In function `ethtool_op_get_settings':
>> sysctl_net.c:(.text+0x1dba0): undefined reference to `phy_ethtool_gset'
   net/built-in.o: In function `ethtool_op_set_settings':
>> sysctl_net.c:(.text+0x1dbdc): undefined reference to `phy_ethtool_sset'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 9ded8c6..e114db9 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -82,6 +82,8 @@  struct net_device;
 /* Some generic methods drivers may use in their ethtool_ops */
 u32 ethtool_op_get_link(struct net_device *dev);
 int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *eti);
+int ethtool_op_get_settings(struct net_device *dev, struct ethtool_cmd *cmd);
+int ethtool_op_set_settings(struct net_device *dev, struct ethtool_cmd *cmd);
 
 /**
  * ethtool_rxfh_indir_default - get default value for RX flow hash indirection
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index f403481..270b6d1 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -50,6 +50,27 @@  int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 }
 EXPORT_SYMBOL(ethtool_op_get_ts_info);
 
+int ethtool_op_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	if (!dev->phydev)
+		return -ENODEV;
+
+	return phy_ethtool_gset(dev->phydev, cmd);
+}
+EXPORT_SYMBOL(ethtool_op_get_settings);
+
+int ethtool_op_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+	if (!capable(CAP_NET_ADMIN))
+		return -EPERM;
+
+	if (!dev->phydev)
+		return -ENODEV;
+
+	return phy_ethtool_sset(dev->phydev, cmd);
+}
+EXPORT_SYMBOL(ethtool_op_set_settings);
+
 /* Handlers for each ethtool command */
 
 #define ETHTOOL_DEV_FEATURE_WORDS	((NETDEV_FEATURE_COUNT + 31) / 32)