diff mbox

[RFC] xgbe: constify get_netdev_ops and get_ethtool_ops

Message ID 20160831085736.29fc6512@xeon-e3
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Stephen Hemminger Aug. 31, 2016, 3:57 p.m. UTC
Casting away const is bad practice. Since this is ARM specific driver
don't have hardware actually test this.

Having getter functions for ops is really unnecessary code bloat, but
not going to touch that.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c     | 4 ++--
 drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c | 4 ++--
 drivers/net/ethernet/amd/xgbe/xgbe.h         | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

Comments

David Miller Aug. 31, 2016, 9:17 p.m. UTC | #1
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Wed, 31 Aug 2016 08:57:36 -0700

> Casting away const is bad practice. Since this is ARM specific driver
> don't have hardware actually test this.
> 
> Having getter functions for ops is really unnecessary code bloat, but
> not going to touch that.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

I'll just apply this, let's see what happens.
Tom Lendacky Sept. 1, 2016, 12:50 a.m. UTC | #2
On 08/31/2016 04:17 PM, David Miller wrote:
> From: Stephen Hemminger <stephen@networkplumber.org>
> Date: Wed, 31 Aug 2016 08:57:36 -0700
> 
>> Casting away const is bad practice. Since this is ARM specific driver
>> don't have hardware actually test this.
>>
>> Having getter functions for ops is really unnecessary code bloat, but
>> not going to touch that.
>>
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> I'll just apply this, let's see what happens.

I should be able to test this in the next few days. I don't expect there
to be an issue. I'll let you know what I find.

Thanks,
Tom

>
Tom Lendacky Sept. 1, 2016, 5:45 p.m. UTC | #3
On 08/31/2016 07:50 PM, Tom Lendacky wrote:
> On 08/31/2016 04:17 PM, David Miller wrote:
>> From: Stephen Hemminger <stephen@networkplumber.org>
>> Date: Wed, 31 Aug 2016 08:57:36 -0700
>>
>>> Casting away const is bad practice. Since this is ARM specific driver
>>> don't have hardware actually test this.
>>>
>>> Having getter functions for ops is really unnecessary code bloat, but
>>> not going to touch that.
>>>
>>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>>
>> I'll just apply this, let's see what happens.
> 
> I should be able to test this in the next few days. I don't expect there
> to be an issue. I'll let you know what I find.

No issues found in build and test. For what it's worth since the patch
is already applied:

Tested-by: Tom Lendacky <thomas.lendacky@amd.com>

> 
> Thanks,
> Tom
> 
>>
diff mbox

Patch

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index a9b2709..7f9216d 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1708,9 +1708,9 @@  static const struct net_device_ops xgbe_netdev_ops = {
 	.ndo_set_features	= xgbe_set_features,
 };
 
-struct net_device_ops *xgbe_get_netdev_ops(void)
+const struct net_device_ops *xgbe_get_netdev_ops(void)
 {
-	return (struct net_device_ops *)&xgbe_netdev_ops;
+	return &xgbe_netdev_ops;
 }
 
 static void xgbe_rx_refresh(struct xgbe_channel *channel)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
index 11d9f0c..4007b42 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c
@@ -623,7 +623,7 @@  static const struct ethtool_ops xgbe_ethtool_ops = {
 	.get_ts_info = xgbe_get_ts_info,
 };
 
-struct ethtool_ops *xgbe_get_ethtool_ops(void)
+const struct ethtool_ops *xgbe_get_ethtool_ops(void)
 {
-	return (struct ethtool_ops *)&xgbe_ethtool_ops;
+	return &xgbe_ethtool_ops;
 }
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index 98d9d63..5dd17dc 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -956,8 +956,9 @@  struct xgbe_prv_data {
 void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *);
 void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *);
 void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *);
-struct net_device_ops *xgbe_get_netdev_ops(void);
-struct ethtool_ops *xgbe_get_ethtool_ops(void);
+const struct net_device_ops *xgbe_get_netdev_ops(void);
+const struct ethtool_ops *xgbe_get_ethtool_ops(void);
+
 #ifdef CONFIG_AMD_XGBE_DCB
 const struct dcbnl_rtnl_ops *xgbe_get_dcbnl_ops(void);
 #endif