summaryrefslogtreecommitdiff
path: root/drivers/net/can/slcan
diff options
context:
space:
mode:
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>2022-07-27 13:49:37 +0300
committerMarc Kleine-Budde <mkl@pengutronix.de>2022-07-27 14:09:01 +0300
commit1851532fd39c674906f83b431650c73e065c4a77 (patch)
treefa815286559f024fb92864e2073339c81902d308 /drivers/net/can/slcan
parenta6e6231ac10a0e94ed298de8297574b8944f7bfa (diff)
downloadlinux-1851532fd39c674906f83b431650c73e065c4a77.tar.xz
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>
Diffstat (limited to 'drivers/net/can/slcan')
-rw-r--r--drivers/net/can/slcan/slcan-core.c2
-rw-r--r--drivers/net/can/slcan/slcan-ethtool.c7
-rw-r--r--drivers/net/can/slcan/slcan.h3
3 files changed, 4 insertions, 8 deletions
diff --git a/drivers/net/can/slcan/slcan-core.c b/drivers/net/can/slcan/slcan-core.c
index dc28e715bbe1..6162e6132ea4 100644
--- a/drivers/net/can/slcan/slcan-core.c
+++ b/drivers/net/can/slcan/slcan-core.c
@@ -866,8 +866,8 @@ static struct slcan *slc_alloc(void)
snprintf(dev->name, sizeof(dev->name), "slcan%d", i);
dev->netdev_ops = &slc_netdev_ops;
+ dev->ethtool_ops = &slcan_ethtool_ops;
dev->base_addr = i;
- slcan_set_ethtool_ops(dev);
sl = netdev_priv(dev);
/* Initialize channel control data */
diff --git a/drivers/net/can/slcan/slcan-ethtool.c b/drivers/net/can/slcan/slcan-ethtool.c
index bf0afdc4e49d..328ae1fb065b 100644
--- a/drivers/net/can/slcan/slcan-ethtool.c
+++ b/drivers/net/can/slcan/slcan-ethtool.c
@@ -52,14 +52,9 @@ static int slcan_get_sset_count(struct net_device *netdev, int sset)
}
}
-static const struct ethtool_ops slcan_ethtool_ops = {
+const struct ethtool_ops slcan_ethtool_ops = {
.get_strings = slcan_get_strings,
.get_priv_flags = slcan_get_priv_flags,
.set_priv_flags = slcan_set_priv_flags,
.get_sset_count = slcan_get_sset_count,
};
-
-void slcan_set_ethtool_ops(struct net_device *netdev)
-{
- netdev->ethtool_ops = &slcan_ethtool_ops;
-}
diff --git a/drivers/net/can/slcan/slcan.h b/drivers/net/can/slcan/slcan.h
index d463c8d99e22..85cedf856db3 100644
--- a/drivers/net/can/slcan/slcan.h
+++ b/drivers/net/can/slcan/slcan.h
@@ -13,6 +13,7 @@
bool slcan_err_rst_on_open(struct net_device *ndev);
int slcan_enable_err_rst_on_open(struct net_device *ndev, bool on);
-void slcan_set_ethtool_ops(struct net_device *ndev);
+
+extern const struct ethtool_ops slcan_ethtool_ops;
#endif /* _SLCAN_H */