diff options
author | Alexander Duyck <alexanderduyck@fb.com> | 2021-03-17 01:30:36 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-03-17 19:42:30 +0100 |
commit | 7888fe53b7066c284e172d98d98d1865d6a9e5a0 (patch) | |
tree | 7774816ad11687302b0fc973e93179e3eda1e586 /net/ethtool | |
parent | Merge tag 'mlx5-updates-2021-03-16' of git://git.kernel.org/pub/scm/linux/ker... (diff) | |
download | linux-7888fe53b7066c284e172d98d98d1865d6a9e5a0.tar.xz linux-7888fe53b7066c284e172d98d98d1865d6a9e5a0.zip |
ethtool: Add common function for filling out strings
Add a function to handle the common pattern of printing a string into the
ethtool strings interface and incrementing the string pointer by the
ETH_GSTRING_LEN. Most of the drivers end up doing this and several have
implemented their own versions of this function so it would make sense to
consolidate on one implementation.
Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool')
-rw-r--r-- | net/ethtool/ioctl.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 24783b71c584..0788cc3b3114 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1844,6 +1844,18 @@ out: return ret; } +__printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsnprintf(*data, ETH_GSTRING_LEN, fmt, args); + va_end(args); + + *data += ETH_GSTRING_LEN; +} +EXPORT_SYMBOL(ethtool_sprintf); + static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) { struct ethtool_value id; |