Skip to content

Commit 10eeb5e

Browse files
goyalbhumikadavem330
authored andcommitted
net: xilinx: constify net_device_ops structure
Declare net_device_ops structure as const as it is only stored in the netdev_ops field of a net_device structure. This field is of type const, so net_device_ops structures having same properties can be made const too. Done using Coccinelle: @r1 disable optional_qualifier@ identifier i; position p; @@ static struct net_device_ops i@p={...}; @ok1@ identifier r1.i; position p; struct net_device ndev; @@ ndev.netdev_ops=&i@p @bad@ position p!={r1.p,ok1.p}; identifier r1.i; @@ i@p @Depends on !bad disable optional_qualifier@ identifier r1.i; @@ +const struct net_device_ops i; File size before: text data bss dec hex filename 6201 744 0 6945 1b21 ethernet/xilinx/xilinx_emaclite.o File size after: text data bss dec hex filename 6745 192 0 6937 1b19 ethernet/xilinx/xilinx_emaclite.o Signed-off-by: Bhumika Goyal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 30bd2f5 commit 10eeb5e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ethernet/xilinx/xilinx_emaclite.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static bool get_bool(struct platform_device *ofdev, const char *s)
10511051
}
10521052
}
10531053

1054-
static struct net_device_ops xemaclite_netdev_ops;
1054+
static const struct net_device_ops xemaclite_netdev_ops;
10551055

10561056
/**
10571057
* xemaclite_of_probe - Probe method for the Emaclite device.
@@ -1205,7 +1205,7 @@ xemaclite_poll_controller(struct net_device *ndev)
12051205
}
12061206
#endif
12071207

1208-
static struct net_device_ops xemaclite_netdev_ops = {
1208+
static const struct net_device_ops xemaclite_netdev_ops = {
12091209
.ndo_open = xemaclite_open,
12101210
.ndo_stop = xemaclite_close,
12111211
.ndo_start_xmit = xemaclite_send,

0 commit comments

Comments
 (0)