constify ethtool_ops structures
Subsystems (10)
cover constify ethtool_ops structures
Constify ethtool_ops structures.
---
drivers/net/ethernet/agere/et131x.c | 2 +- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- drivers/net/ethernet/hisilicon/hip04_eth.c | 2 +- drivers/net/ethernet/hisilicon/hisi_femac.c | 2 +- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 2 +- drivers/staging/slicoss/slicoss.c | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-)
PATCH 1/6 staging: slicoss: constify ethtool_ops structures
Check for ethtool_ops structures that are only stored in the ethtool_ops field of a net_device structure or passed as the second argument to netdev_set_default_ethtool_ops. These contexts are declared const, so ethtool_ops structures that have these properties can be declared as const also.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct ethtool_ops i@p = { ... };
@ok1@
identifier r.i;
struct net_device e;
position p;
@@
e.ethtool_ops = &i@p;
@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)
@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct ethtool_ops i = { ... };
// </smpl>
--- drivers/staging/slicoss/slicoss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slicoss.c +2 -2
@@ -124,7 +124,7 @@ static const struct pci_device_id slic_pci_tbl[] = { { 0 } }; -static struct ethtool_ops slic_ethtool_ops; +static const struct ethtool_ops slic_ethtool_ops;MODULE_DEVICE_TABLE (pci, slic_pci_tbl);
@@ -3128,7 +3128,7 @@ static void __exit slic_module_cleanup(void)pci_unregister_driver (&slic_driver); } -static struct ethtool_ops slic_ethtool_ops = { +static const struct ethtool_ops slic_ethtool_ops = { .get_coalesce = slic_get_coalesce, .set_coalesce = slic_set_coalesce };
PATCH 2/6 net: ethernet: et131x: constify ethtool_ops structures
In reply to Julia LawallCheck for ethtool_ops structures that are only stored in the ethtool_ops field of a net_device structure or passed as the second argument to netdev_set_default_ethtool_ops. These contexts are declared const, so ethtool_ops structures that have these properties can be declared as const also.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct ethtool_ops i@p = { ... };
@ok1@
identifier r.i;
struct net_device e;
position p;
@@
e.ethtool_ops = &i@p;
@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)
@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct ethtool_ops i = { ... };
// </smpl>
--- drivers/net/ethernet/agere/et131x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/agere/et131x.c +1 -1
@@ -2961,7 +2961,7 @@ static void et131x_get_drvinfo(struct net_device *netdev, sizeof(info->bus_info)); } -static struct ethtool_ops et131x_ethtool_ops = { +static const struct ethtool_ops et131x_ethtool_ops = { .get_drvinfo = et131x_get_drvinfo, .get_regs_len = et131x_get_regs_len, .get_regs = et131x_get_regs,
Re: [PATCH 2/6] net: ethernet: et131x: constify ethtool_ops structures
Quoted 44 lines · Julia Lawall
Check for
ethtool_opsstructures that are only stored in theethtool_opsfield of anet_devicestructure or passed as the second argument tonetdev_set_default_ethtool_ops. These contexts are declared const, soethtool_opsstructures that have these properties can be declared as const also.The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static structethtool_opsi@p = { ... };@ok1@
identifier r.i;
structnet_devicee;
position p;
@@
e.ethtool_ops = &i@p;@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
structethtool_opsi = { ... };
// </smpl>
Quoted 1 line
Signed-off-by Julia Lawall <[email protected]>
Looks good, thanks.
PATCH 3/6 net: bcmgenet: constify ethtool_ops structures
In reply to Julia LawallCheck for ethtool_ops structures that are only stored in the ethtool_ops field of a net_device structure or passed as the second argument to netdev_set_default_ethtool_ops. These contexts are declared const, so ethtool_ops structures that have these properties can be declared as const also.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct ethtool_ops i@p = { ... };
@ok1@
identifier r.i;
struct net_device e;
position p;
@@
e.ethtool_ops = &i@p;
@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)
@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct ethtool_ops i = { ... };
// </smpl>
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +1 -1
@@ -973,7 +973,7 @@ static int bcmgenet_nway_reset(struct net_device *dev) }/* standard ethtool support functions. */ -static struct ethtool_ops bcmgenet_ethtool_ops = { +static const struct ethtool_ops bcmgenet_ethtool_ops = { .get_strings = bcmgenet_get_strings, .get_sset_count = bcmgenet_get_sset_count, .get_ethtool_stats = bcmgenet_get_ethtool_stats,
Re: [PATCH 3/6] net: bcmgenet: constify ethtool_ops structures
Quoted 44 lines · Julia Lawall
Check for
ethtool_opsstructures that are only stored in theethtool_opsfield of anet_devicestructure or passed as the second argument tonetdev_set_default_ethtool_ops. These contexts are declared const, soethtool_opsstructures that have these properties can be declared as const also.The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static structethtool_opsi@p = { ... };@ok1@
identifier r.i;
structnet_devicee;
position p;
@@
e.ethtool_ops = &i@p;@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
structethtool_opsi = { ... };
// </smpl>
Quoted 1 line
Signed-off-by Julia Lawall <[email protected]>
Signature · 1 line
Florian
PATCH 4/6 net: hisilicon: constify ethtool_ops structures
In reply to Julia LawallCheck for ethtool_ops structures that are only stored in the ethtool_ops field of a net_device structure or passed as the second argument to netdev_set_default_ethtool_ops. These contexts are declared const, so ethtool_ops structures that have these properties can be declared as const also.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct ethtool_ops i@p = { ... };
@ok1@
identifier r.i;
struct net_device e;
position p;
@@
e.ethtool_ops = &i@p;
@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)
@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct ethtool_ops i = { ... };
// </smpl>
--- drivers/net/ethernet/hisilicon/hip04_eth.c | 2 +- drivers/net/ethernet/hisilicon/hisi_femac.c | 2 +- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/hisilicon/hip04_eth.c +1 -1
@@ -755,7 +755,7 @@ static void hip04_get_drvinfo(struct net_device *netdev,strlcpy (drvinfo->version,DRV_VERSION ,sizeof (drvinfo->version)); } -static struct ethtool_ops hip04_ethtool_ops = { +static const struct ethtool_ops hip04_ethtool_ops = { .get_coalesce = hip04_get_coalesce, .set_coalesce = hip04_set_coalesce, .get_drvinfo = hip04_get_drvinfo,
drivers/net/ethernet/hisilicon/hisi_femac.c +1 -1
@@ -699,7 +699,7 @@ static int hisi_femac_net_ioctl(struct net_device *dev,return phy_mii_ioctl (dev->phydev, ifreq, cmd); } -static struct ethtool_ops hisi_femac_ethtools_ops = { +static const struct ethtool_ops hisi_femac_ethtools_ops = { .get_link = ethtool_op_get_link, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings,
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +1 -1
@@ -750,7 +750,7 @@ static const struct net_device_ops hix5hd2_netdev_ops = { .ndo_set_mac_address = hix5hd2_net_set_mac_address, }; -static struct ethtool_ops hix5hd2_ethtools_ops = { +static const struct ethtool_ops hix5hd2_ethtools_ops = { .get_link = ethtool_op_get_link, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings,
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +1 -1
@@ -1264,7 +1264,7 @@ static int hns_get_rxnfc(struct net_device *netdev,return 0 ; } -static struct ethtool_ops hns_ethtool_ops = { +static const struct ethtool_ops hns_ethtool_ops = { .get_drvinfo = hns_nic_get_drvinfo, .get_link = hns_nic_get_link, .get_settings = hns_nic_get_settings,
PATCH 5/6 dwc_eth_qos: constify ethtool_ops structures
In reply to Julia LawallCheck for ethtool_ops structures that are only stored in the ethtool_ops field of a net_device structure or passed as the second argument to netdev_set_default_ethtool_ops. These contexts are declared const, so ethtool_ops structures that have these properties can be declared as const also.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct ethtool_ops i@p = { ... };
@ok1@
identifier r.i;
struct net_device e;
position p;
@@
e.ethtool_ops = &i@p;
@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)
@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct ethtool_ops i = { ... };
// </smpl>
--- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/synopsys/dwc_eth_qos.c +1 -1
@@ -2743,7 +2743,7 @@ static void dwceqos_set_msglevel(struct net_device *ndev, u32 msglevel) lp->msg_enable = msglevel; } -static struct ethtool_ops dwceqos_ethtool_ops = { +static const struct ethtool_ops dwceqos_ethtool_ops = { .get_drvinfo = dwceqos_get_drvinfo, .get_link = ethtool_op_get_link, .get_pauseparam = dwceqos_get_pauseparam,
PATCH 6/6 net: systemport: constify ethtool_ops structures
In reply to Julia LawallCheck for ethtool_ops structures that are only stored in the ethtool_ops field of a net_device structure or passed as the second argument to netdev_set_default_ethtool_ops. These contexts are declared const, so ethtool_ops structures that have these properties can be declared as const also.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct ethtool_ops i@p = { ... };
@ok1@
identifier r.i;
struct net_device e;
position p;
@@
e.ethtool_ops = &i@p;
@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)
@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct ethtool_ops i = { ... };
// </smpl>
--- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bcmsysport.c +1 -1
@@ -1692,7 +1692,7 @@ static int bcm_sysport_stop(struct net_device *dev)return 0 ; } -static struct ethtool_ops bcm_sysport_ethtool_ops = { +static const struct ethtool_ops bcm_sysport_ethtool_ops = { .get_drvinfo = bcm_sysport_get_drvinfo, .get_msglevel = bcm_sysport_get_msglvl, .set_msglevel = bcm_sysport_set_msglvl,
Re: [PATCH 6/6] net: systemport: constify ethtool_ops structures
Quoted 44 lines · Julia Lawall
Check for
ethtool_opsstructures that are only stored in theethtool_opsfield of anet_devicestructure or passed as the second argument tonetdev_set_default_ethtool_ops. These contexts are declared const, soethtool_opsstructures that have these properties can be declared as const also.The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static structethtool_opsi@p = { ... };@ok1@
identifier r.i;
structnet_devicee;
position p;
@@
e.ethtool_ops = &i@p;@ok2@
identifier r.i;
expression e;
position p;
@@netdev_set_default_ethtool_ops(e, &i@p)@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
@@
i@p@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
structethtool_opsi = { ... };
// </smpl>
Quoted 1 line
Signed-off-by Julia Lawall <[email protected]>
Signature · 1 line
Florian
Quoted 14 lines · On Wed, 31 Aug 2016 09:30:42 +0200 Julia Lawall <[email protected]> wrote:
Constify
ethtool_opsstructures.---
drivers/net/ethernet/agere/et131x.c | 2 +- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- drivers/net/ethernet/hisilicon/hip04_eth.c | 2 +- drivers/net/ethernet/hisilicon/hisi_femac.c | 2 +- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 2 +- drivers/staging/slicoss/slicoss.c | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-)
Quoted 4 lines
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Other drivers with same type of issue
drivers/net/ethernet/mediatek/mtk_eth_soc.c:static struct ethtool_ops mtk_ethtool_ops = { drivers/net/ethernet/synopsys/dwc_eth_qos.c:static struct ethtool_ops dwceqos_ethtool_ops = { drivers/net/ethernet/xilinx/xilinx_axienet_main.c:static struct ethtool_ops axienet_ethtool_ops = { drivers/net/usb/r8152.c:static struct ethtool_ops ops = { drivers/staging/netlogic/xlr_net.c:static struct ethtool_ops xlr_ethtool_ops = {
Quoted 22 lines · Stephen Hemminger
Quoted 14 lines · On Wed, 31 Aug 2016 09:30:42 +0200 Julia Lawall <[email protected]> wrote:
Constify
ethtool_opsstructures.---
drivers/net/ethernet/agere/et131x.c | 2 +- drivers/net/ethernet/broadcom/bcmsysport.c | 2 +- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 2 +- drivers/net/ethernet/hisilicon/hip04_eth.c | 2 +- drivers/net/ethernet/hisilicon/hisi_femac.c | 2 +- drivers/net/ethernet/hisilicon/hix5hd2_gmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 2 +- drivers/staging/slicoss/slicoss.c | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-)Quoted 4 lines
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Quoted 8 lines
Other drivers with same type of issue
drivers/net/ethernet/mediatek/mtk_eth_soc.c:static struct
ethtool_opsmtk_ethtool_ops= { drivers/net/ethernet/synopsys/dwc_eth_qos.c:static structethtool_opsdwceqos_ethtool_ops= { drivers/net/ethernet/xilinx/xilinx_axienet_main.c:static structethtool_opsaxienet_ethtool_ops= { drivers/net/usb/r8152.c:static structethtool_opsops = { drivers/staging/netlogic/xlr_net.c:static structethtool_opsxlr_ethtool_ops= {
Thanks. Probably they don't compile for x86, or at least not with make allyesconfig. I can check on them.
julia
RFC 1/1 xgbe: constify get_netdev_ops and get_ethtool_ops
In reply to Julia LawallCasting 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.
--- 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(-)
drivers/net/ethernet/amd/xgbe/xgbe-drv.c +2 -2
@@ -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)
drivers/net/ethernet/amd/xgbe/xgbe-ethtool.c +2 -2
@@ -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; }
drivers/net/ethernet/amd/xgbe/xgbe.h +3 -2
@@ -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
Signature · 1 line
2.9.3
David Miller
maintainerRe: [RFC] xgbe: constify get_netdev_ops and get_ethtool_ops
From: Stephen Hemminger <[email protected]>
Date: Wed, 31 Aug 2016 08:57:36 -0700
Quoted 7 lines
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 <[email protected]>
I'll just apply this, let's see what happens.
Re: [RFC] xgbe: constify get_netdev_ops and get_ethtool_ops
Quoted 6 lines · David Miller
From: Stephen Hemminger <[email protected]>
Date: Wed, 31 Aug 2016 08:57:36 -0700Quoted 3 lines
Casting away const is bad practice. Since this is ARM specific driver don't have hardware actually test this.
Quoted 6 lines
Quoted 4 lines
Having getter functions for ops is really unnecessary code bloat, but not going to touch that.
Signed-off-by Stephen Hemminger <[email protected]>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
Quoted 1 line
Tom Lendacky
Tested-byRe: [RFC] xgbe: constify get_netdev_ops and get_ethtool_ops
Quoted 10 lines · Tom Lendacky
Quoted 9 lines · David Miller
From: Stephen Hemminger <[email protected]>
Date: Wed, 31 Aug 2016 08:57:36 -0700Quoted 6 lines
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.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Stephen Hemminger <[email protected]>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:
Quoted 5 lines
Thanks,
TomQuoted 1 line
David Miller
maintainerFrom: Julia Lawall <[email protected]>
Date: Wed, 31 Aug 2016 09:30:42 +0200
Quoted 1 line
Constify
ethtool_opsstructures.
Patches 2-6 applied, thanks.