Commit 4edfe3e4 authored by justinstitt@google.com's avatar justinstitt@google.com Committed by Hao Chen
Browse files

ethtool: Implement ethtool_puts()

maillist inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IBU56J
CVE: NA

Reference: https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2a48c635fd9a48699805bbfeee1e4b94b8fe819d



----------------------------------------------------------------------

Use strscpy() to implement ethtool_puts().

Functionally the same as ethtool_sprintf() when it's used with two
arguments or with just "%s" format specifier.

Signed-off-by: default avatarJustin Stitt <justinstitt@google.com>
Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarMadhuri Sripada <madhuri.sripada@microchip.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarHao Chen <chenhao418@huawei.com>
parent 61191a56
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1064,4 +1064,17 @@ static inline int ethtool_mm_frag_size_min_to_add(u32 val_min, u32 *val_add,
 * next string.
 */
extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...);

/**
 * ethtool_puts - Write string to ethtool string data
 * @data: Pointer to a pointer to the start of string to update
 * @str: String to write
 *
 * Write string to *data without a trailing newline. Update *data
 * to point at start of next string.
 *
 * Prefer this function to ethtool_sprintf() when given only
 * two arguments or if @fmt is just "%s".
 */
extern void ethtool_puts(u8 **data, const char *str);
#endif /* _LINUX_ETHTOOL_H */
+7 −0
Original line number Diff line number Diff line
@@ -1992,6 +1992,13 @@ __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...)
}
EXPORT_SYMBOL(ethtool_sprintf);

void ethtool_puts(u8 **data, const char *str)
{
	strscpy(*data, str, ETH_GSTRING_LEN);
	*data += ETH_GSTRING_LEN;
}
EXPORT_SYMBOL(ethtool_puts);

static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
{
	struct ethtool_value id;