Skip to content

Commit 30bd2f5

Browse files
goyalbhumikadavem330
authored andcommitted
net: moxa: constify net_device_ops structures
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 4821 744 0 5565 15bd ethernet/moxa/moxart_ether.o File size after: text data bss dec hex filename 5373 192 0 5565 15bd ethernet/moxa/moxart_ether.o Signed-off-by: Bhumika Goyal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4404323 commit 30bd2f5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/moxa/moxart_ether.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static void moxart_mac_set_rx_mode(struct net_device *ndev)
436436
spin_unlock_irq(&priv->txlock);
437437
}
438438

439-
static struct net_device_ops moxart_netdev_ops = {
439+
static const struct net_device_ops moxart_netdev_ops = {
440440
.ndo_open = moxart_mac_open,
441441
.ndo_stop = moxart_mac_stop,
442442
.ndo_start_xmit = moxart_mac_start_xmit,

0 commit comments

Comments
 (0)