Skip to content

Commit

Permalink
net: xilinx: constify net_device_ops structure
Browse files Browse the repository at this point in the history
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 <bhumirks@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bhumika Goyal authored and David S. Miller committed Jan 23, 2017
1 parent 30bd2f5 commit 10eeb5e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/xilinx/xilinx_emaclite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ static bool get_bool(struct platform_device *ofdev, const char *s)
}
}

static struct net_device_ops xemaclite_netdev_ops;
static const struct net_device_ops xemaclite_netdev_ops;

/**
* xemaclite_of_probe - Probe method for the Emaclite device.
Expand Down Expand Up @@ -1205,7 +1205,7 @@ xemaclite_poll_controller(struct net_device *ndev)
}
#endif

static struct net_device_ops xemaclite_netdev_ops = {
static const struct net_device_ops xemaclite_netdev_ops = {
.ndo_open = xemaclite_open,
.ndo_stop = xemaclite_close,
.ndo_start_xmit = xemaclite_send,
Expand Down

0 comments on commit 10eeb5e

Please sign in to comment.