Skip to content

Commit 20c6e05

Browse files
kuba-moodavem330
authored andcommitted
ethtool: untangle the linkmode and ethtool headers
Commit 26c5334 ("ethtool: Add forced speed to supported link modes maps") added a dependency between ethtool.h and linkmode.h. The dependency in the opposite direction already exists so the new code was inserted in an awkward place. The reason for ethtool.h to include linkmode.h, is that ethtool_forced_speed_maps_init() is a static inline helper. That's not really necessary. Signed-off-by: Jakub Kicinski <[email protected]> Reviewed-by: Paul Greenwalt <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b4a11b2 commit 20c6e05

File tree

3 files changed

+37
-35
lines changed

3 files changed

+37
-35
lines changed

include/linux/ethtool.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef _LINUX_ETHTOOL_H
1414
#define _LINUX_ETHTOOL_H
1515

16-
#include <linux/linkmode.h>
1716
#include <linux/bitmap.h>
1817
#include <linux/compat.h>
1918
#include <linux/if_ether.h>
@@ -1070,23 +1069,6 @@ struct ethtool_forced_speed_map {
10701069
.arr_size = ARRAY_SIZE(prefix##_##value), \
10711070
}
10721071

1073-
/**
1074-
* ethtool_forced_speed_maps_init
1075-
* @maps: Pointer to an array of Ethtool forced speed map
1076-
* @size: Array size
1077-
*
1078-
* Initialize an array of Ethtool forced speed map to Ethtool link modes. This
1079-
* should be called during driver module init.
1080-
*/
1081-
static inline void
1082-
ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size)
1083-
{
1084-
for (u32 i = 0; i < size; i++) {
1085-
struct ethtool_forced_speed_map *map = &maps[i];
1086-
1087-
linkmode_set_bit_array(map->cap_arr, map->arr_size, map->caps);
1088-
map->cap_arr = NULL;
1089-
map->arr_size = 0;
1090-
}
1091-
}
1072+
void
1073+
ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size);
10921074
#endif /* _LINUX_ETHTOOL_H */

include/linux/linkmode.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22
#define __LINKMODE_H
33

44
#include <linux/bitmap.h>
5-
6-
static inline void linkmode_set_bit(int nr, volatile unsigned long *addr)
7-
{
8-
__set_bit(nr, addr);
9-
}
10-
11-
static inline void linkmode_set_bit_array(const int *array, int array_size,
12-
unsigned long *addr)
13-
{
14-
int i;
15-
16-
for (i = 0; i < array_size; i++)
17-
linkmode_set_bit(array[i], addr);
18-
}
19-
205
#include <linux/ethtool.h>
216
#include <uapi/linux/ethtool.h>
227

@@ -53,6 +38,11 @@ static inline int linkmode_andnot(unsigned long *dst, const unsigned long *src1,
5338
return bitmap_andnot(dst, src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS);
5439
}
5540

41+
static inline void linkmode_set_bit(int nr, volatile unsigned long *addr)
42+
{
43+
__set_bit(nr, addr);
44+
}
45+
5646
static inline void linkmode_clear_bit(int nr, volatile unsigned long *addr)
5747
{
5848
__clear_bit(nr, addr);
@@ -72,6 +62,15 @@ static inline int linkmode_test_bit(int nr, const volatile unsigned long *addr)
7262
return test_bit(nr, addr);
7363
}
7464

65+
static inline void linkmode_set_bit_array(const int *array, int array_size,
66+
unsigned long *addr)
67+
{
68+
int i;
69+
70+
for (i = 0; i < array_size; i++)
71+
linkmode_set_bit(array[i], addr);
72+
}
73+
7574
static inline int linkmode_equal(const unsigned long *src1,
7675
const unsigned long *src2)
7776
{

net/ethtool/common.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,3 +685,24 @@ ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings,
685685
link_ksettings->base.duplex = link_info->duplex;
686686
}
687687
EXPORT_SYMBOL_GPL(ethtool_params_from_link_mode);
688+
689+
/**
690+
* ethtool_forced_speed_maps_init
691+
* @maps: Pointer to an array of Ethtool forced speed map
692+
* @size: Array size
693+
*
694+
* Initialize an array of Ethtool forced speed map to Ethtool link modes. This
695+
* should be called during driver module init.
696+
*/
697+
void
698+
ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size)
699+
{
700+
for (u32 i = 0; i < size; i++) {
701+
struct ethtool_forced_speed_map *map = &maps[i];
702+
703+
linkmode_set_bit_array(map->cap_arr, map->arr_size, map->caps);
704+
map->cap_arr = NULL;
705+
map->arr_size = 0;
706+
}
707+
}
708+
EXPORT_SYMBOL_GPL(ethtool_forced_speed_maps_init);

0 commit comments

Comments
 (0)