Skip to content

Commit f4b87ed

Browse files
committed
Merge branch 'use-hwmon_channel_info-macro-to-simplify-code'
Huisong Li says: ==================== Use HWMON_CHANNEL_INFO macro to simplify code The HWMON_CHANNEL_INFO macro is provided by hwmon.h and used widely by many other drivers. This series use HWMON_CHANNEL_INFO macro to simplify code in net subsystem. Note: These patches do not depend on each other. Put them togeter just for belonging to the same subsystem. ==================== Link: https://patch.msgid.link/20250210054710.12855-1-lihuisong@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 4d3f687 + d6085a2 commit f4b87ed

File tree

5 files changed

+17
-117
lines changed

5 files changed

+17
-117
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,9 @@ static const struct hwmon_ops aq_hwmon_ops = {
113113
.read_string = aq_hwmon_read_string,
114114
};
115115

116-
static u32 aq_hwmon_temp_config[] = {
117-
HWMON_T_INPUT | HWMON_T_LABEL,
118-
HWMON_T_INPUT | HWMON_T_LABEL,
119-
0,
120-
};
121-
122-
static const struct hwmon_channel_info aq_hwmon_temp = {
123-
.type = hwmon_temp,
124-
.config = aq_hwmon_temp_config,
125-
};
126-
127116
static const struct hwmon_channel_info * const aq_hwmon_info[] = {
128-
&aq_hwmon_temp,
117+
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL,
118+
HWMON_T_INPUT | HWMON_T_LABEL),
129119
NULL,
130120
};
131121

drivers/net/ethernet/netronome/nfp/nfp_hwmon.c

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,42 +83,12 @@ nfp_hwmon_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,
8383
return 0;
8484
}
8585

86-
static u32 nfp_chip_config[] = {
87-
HWMON_C_REGISTER_TZ,
88-
0
89-
};
90-
91-
static const struct hwmon_channel_info nfp_chip = {
92-
.type = hwmon_chip,
93-
.config = nfp_chip_config,
94-
};
95-
96-
static u32 nfp_temp_config[] = {
97-
HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT,
98-
0
99-
};
100-
101-
static const struct hwmon_channel_info nfp_temp = {
102-
.type = hwmon_temp,
103-
.config = nfp_temp_config,
104-
};
105-
106-
static u32 nfp_power_config[] = {
107-
HWMON_P_INPUT | HWMON_P_MAX,
108-
HWMON_P_INPUT,
109-
HWMON_P_INPUT,
110-
0
111-
};
112-
113-
static const struct hwmon_channel_info nfp_power = {
114-
.type = hwmon_power,
115-
.config = nfp_power_config,
116-
};
117-
11886
static const struct hwmon_channel_info * const nfp_hwmon_info[] = {
119-
&nfp_chip,
120-
&nfp_temp,
121-
&nfp_power,
87+
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
88+
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT),
89+
HWMON_CHANNEL_INFO(power, HWMON_P_INPUT | HWMON_P_MAX,
90+
HWMON_P_INPUT,
91+
HWMON_P_INPUT),
12292
NULL
12393
};
12494

drivers/net/phy/aquantia/aquantia_hwmon.c

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,13 @@ static const struct hwmon_ops aqr_hwmon_ops = {
172172
.write = aqr_hwmon_write,
173173
};
174174

175-
static u32 aqr_hwmon_chip_config[] = {
176-
HWMON_C_REGISTER_TZ,
177-
0,
178-
};
179-
180-
static const struct hwmon_channel_info aqr_hwmon_chip = {
181-
.type = hwmon_chip,
182-
.config = aqr_hwmon_chip_config,
183-
};
184-
185-
static u32 aqr_hwmon_temp_config[] = {
186-
HWMON_T_INPUT |
187-
HWMON_T_MAX | HWMON_T_MIN |
188-
HWMON_T_MAX_ALARM | HWMON_T_MIN_ALARM |
189-
HWMON_T_CRIT | HWMON_T_LCRIT |
190-
HWMON_T_CRIT_ALARM | HWMON_T_LCRIT_ALARM,
191-
0,
192-
};
193-
194-
static const struct hwmon_channel_info aqr_hwmon_temp = {
195-
.type = hwmon_temp,
196-
.config = aqr_hwmon_temp_config,
197-
};
198-
199175
static const struct hwmon_channel_info * const aqr_hwmon_info[] = {
200-
&aqr_hwmon_chip,
201-
&aqr_hwmon_temp,
176+
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
177+
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT |
178+
HWMON_T_MAX | HWMON_T_MIN |
179+
HWMON_T_MAX_ALARM | HWMON_T_MIN_ALARM |
180+
HWMON_T_CRIT | HWMON_T_LCRIT |
181+
HWMON_T_CRIT_ALARM | HWMON_T_LCRIT_ALARM),
202182
NULL,
203183
};
204184

drivers/net/phy/marvell.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,33 +3124,13 @@ static umode_t marvell_hwmon_is_visible(const void *data,
31243124
}
31253125
}
31263126

3127-
static u32 marvell_hwmon_chip_config[] = {
3128-
HWMON_C_REGISTER_TZ,
3129-
0
3130-
};
3131-
3132-
static const struct hwmon_channel_info marvell_hwmon_chip = {
3133-
.type = hwmon_chip,
3134-
.config = marvell_hwmon_chip_config,
3135-
};
3136-
31373127
/* we can define HWMON_T_CRIT and HWMON_T_MAX_ALARM even though these are not
31383128
* defined for all PHYs, because the hwmon code checks whether the attributes
31393129
* exists via the .is_visible method
31403130
*/
3141-
static u32 marvell_hwmon_temp_config[] = {
3142-
HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_MAX_ALARM,
3143-
0
3144-
};
3145-
3146-
static const struct hwmon_channel_info marvell_hwmon_temp = {
3147-
.type = hwmon_temp,
3148-
.config = marvell_hwmon_temp_config,
3149-
};
3150-
31513131
static const struct hwmon_channel_info * const marvell_hwmon_info[] = {
3152-
&marvell_hwmon_chip,
3153-
&marvell_hwmon_temp,
3132+
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
3133+
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_MAX_ALARM),
31543134
NULL
31553135
};
31563136

drivers/net/phy/marvell10g.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -230,29 +230,9 @@ static const struct hwmon_ops mv3310_hwmon_ops = {
230230
.read = mv3310_hwmon_read,
231231
};
232232

233-
static u32 mv3310_hwmon_chip_config[] = {
234-
HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL,
235-
0,
236-
};
237-
238-
static const struct hwmon_channel_info mv3310_hwmon_chip = {
239-
.type = hwmon_chip,
240-
.config = mv3310_hwmon_chip_config,
241-
};
242-
243-
static u32 mv3310_hwmon_temp_config[] = {
244-
HWMON_T_INPUT,
245-
0,
246-
};
247-
248-
static const struct hwmon_channel_info mv3310_hwmon_temp = {
249-
.type = hwmon_temp,
250-
.config = mv3310_hwmon_temp_config,
251-
};
252-
253233
static const struct hwmon_channel_info * const mv3310_hwmon_info[] = {
254-
&mv3310_hwmon_chip,
255-
&mv3310_hwmon_temp,
234+
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL),
235+
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
256236
NULL,
257237
};
258238

0 commit comments

Comments
 (0)