Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: slcan: export slcan_ethtool_ops and remove slcan_set_ethtool_ops()

The function slcan_set_ethtool_ops() does one thing: populate
net_device::ethtool_ops. Instead, it is possible to directly assign
this field and remove one function call and slightly reduce the object
size. To do so, export slcan_ethtool_ops so it becomes visible to
sclan-core.c.

This patch reduces the footprint by 14 bytes:

| $ ./scripts/bloat-o-meter drivers/net/can/slcan/slcan.{old,new}.o
| drivers/net/can/slcan/slcan.o
| add/remove: 0/1 grow/shrink: 1/0 up/down: 15/-29 (-14)
| Function old new delta
| slcan_open 1010 1025 +15
| slcan_set_ethtool_ops 29 - -29
| Total: Before=11115, After=11101, chg -0.13%

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://lore.kernel.org/all/20220727104939.279022-2-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Vincent Mailhol and committed by
Marc Kleine-Budde
1851532f a6e6231a

+4 -8
+1 -1
drivers/net/can/slcan/slcan-core.c
··· 866 866 867 867 snprintf(dev->name, sizeof(dev->name), "slcan%d", i); 868 868 dev->netdev_ops = &slc_netdev_ops; 869 + dev->ethtool_ops = &slcan_ethtool_ops; 869 870 dev->base_addr = i; 870 - slcan_set_ethtool_ops(dev); 871 871 sl = netdev_priv(dev); 872 872 873 873 /* Initialize channel control data */
+1 -6
drivers/net/can/slcan/slcan-ethtool.c
··· 52 52 } 53 53 } 54 54 55 - static const struct ethtool_ops slcan_ethtool_ops = { 55 + const struct ethtool_ops slcan_ethtool_ops = { 56 56 .get_strings = slcan_get_strings, 57 57 .get_priv_flags = slcan_get_priv_flags, 58 58 .set_priv_flags = slcan_set_priv_flags, 59 59 .get_sset_count = slcan_get_sset_count, 60 60 }; 61 - 62 - void slcan_set_ethtool_ops(struct net_device *netdev) 63 - { 64 - netdev->ethtool_ops = &slcan_ethtool_ops; 65 - }
+2 -1
drivers/net/can/slcan/slcan.h
··· 13 13 14 14 bool slcan_err_rst_on_open(struct net_device *ndev); 15 15 int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on); 16 - void slcan_set_ethtool_ops(struct net_device *ndev); 16 + 17 + extern const struct ethtool_ops slcan_ethtool_ops; 17 18 18 19 #endif /* _SLCAN_H */