Skip to content

Commit

Permalink
ethtool: Implement ethtool_puts()
Browse files Browse the repository at this point in the history
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: Justin Stitt <[email protected]>
Reviewed-by: Przemek Kitszel <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Reviewed-by: Madhuri Sripada <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
JustinStitt authored and davem330 committed Dec 8, 2023
1 parent 09b4894 commit 2a48c63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/linux/ethtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,19 @@ int ethtool_get_ts_info_by_layer(struct net_device *dev, struct ethtool_ts_info
*/
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);

/* Link mode to forced speed capabilities maps */
struct ethtool_forced_speed_map {
u32 speed;
Expand Down
7 changes: 7 additions & 0 deletions net/ethtool/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,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;
Expand Down

0 comments on commit 2a48c63

Please sign in to comment.