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>
This commit is contained in:
Jakub Kicinski
2025-02-11 17:07:05 -08:00
5 changed files with 17 additions and 117 deletions

View File

@@ -113,19 +113,9 @@ static const struct hwmon_ops aq_hwmon_ops = {
.read_string = aq_hwmon_read_string,
};
static u32 aq_hwmon_temp_config[] = {
HWMON_T_INPUT | HWMON_T_LABEL,
HWMON_T_INPUT | HWMON_T_LABEL,
0,
};
static const struct hwmon_channel_info aq_hwmon_temp = {
.type = hwmon_temp,
.config = aq_hwmon_temp_config,
};
static const struct hwmon_channel_info * const aq_hwmon_info[] = {
&aq_hwmon_temp,
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_LABEL,
HWMON_T_INPUT | HWMON_T_LABEL),
NULL,
};

View File

@@ -83,42 +83,12 @@ nfp_hwmon_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,
return 0;
}
static u32 nfp_chip_config[] = {
HWMON_C_REGISTER_TZ,
0
};
static const struct hwmon_channel_info nfp_chip = {
.type = hwmon_chip,
.config = nfp_chip_config,
};
static u32 nfp_temp_config[] = {
HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT,
0
};
static const struct hwmon_channel_info nfp_temp = {
.type = hwmon_temp,
.config = nfp_temp_config,
};
static u32 nfp_power_config[] = {
HWMON_P_INPUT | HWMON_P_MAX,
HWMON_P_INPUT,
HWMON_P_INPUT,
0
};
static const struct hwmon_channel_info nfp_power = {
.type = hwmon_power,
.config = nfp_power_config,
};
static const struct hwmon_channel_info * const nfp_hwmon_info[] = {
&nfp_chip,
&nfp_temp,
&nfp_power,
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT),
HWMON_CHANNEL_INFO(power, HWMON_P_INPUT | HWMON_P_MAX,
HWMON_P_INPUT,
HWMON_P_INPUT),
NULL
};

View File

@@ -172,33 +172,13 @@ static const struct hwmon_ops aqr_hwmon_ops = {
.write = aqr_hwmon_write,
};
static u32 aqr_hwmon_chip_config[] = {
HWMON_C_REGISTER_TZ,
0,
};
static const struct hwmon_channel_info aqr_hwmon_chip = {
.type = hwmon_chip,
.config = aqr_hwmon_chip_config,
};
static u32 aqr_hwmon_temp_config[] = {
HWMON_T_INPUT |
HWMON_T_MAX | HWMON_T_MIN |
HWMON_T_MAX_ALARM | HWMON_T_MIN_ALARM |
HWMON_T_CRIT | HWMON_T_LCRIT |
HWMON_T_CRIT_ALARM | HWMON_T_LCRIT_ALARM,
0,
};
static const struct hwmon_channel_info aqr_hwmon_temp = {
.type = hwmon_temp,
.config = aqr_hwmon_temp_config,
};
static const struct hwmon_channel_info * const aqr_hwmon_info[] = {
&aqr_hwmon_chip,
&aqr_hwmon_temp,
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT |
HWMON_T_MAX | HWMON_T_MIN |
HWMON_T_MAX_ALARM | HWMON_T_MIN_ALARM |
HWMON_T_CRIT | HWMON_T_LCRIT |
HWMON_T_CRIT_ALARM | HWMON_T_LCRIT_ALARM),
NULL,
};

View File

@@ -3124,33 +3124,13 @@ static umode_t marvell_hwmon_is_visible(const void *data,
}
}
static u32 marvell_hwmon_chip_config[] = {
HWMON_C_REGISTER_TZ,
0
};
static const struct hwmon_channel_info marvell_hwmon_chip = {
.type = hwmon_chip,
.config = marvell_hwmon_chip_config,
};
/* we can define HWMON_T_CRIT and HWMON_T_MAX_ALARM even though these are not
* defined for all PHYs, because the hwmon code checks whether the attributes
* exists via the .is_visible method
*/
static u32 marvell_hwmon_temp_config[] = {
HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_MAX_ALARM,
0
};
static const struct hwmon_channel_info marvell_hwmon_temp = {
.type = hwmon_temp,
.config = marvell_hwmon_temp_config,
};
static const struct hwmon_channel_info * const marvell_hwmon_info[] = {
&marvell_hwmon_chip,
&marvell_hwmon_temp,
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_MAX_ALARM),
NULL
};

View File

@@ -230,29 +230,9 @@ static const struct hwmon_ops mv3310_hwmon_ops = {
.read = mv3310_hwmon_read,
};
static u32 mv3310_hwmon_chip_config[] = {
HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL,
0,
};
static const struct hwmon_channel_info mv3310_hwmon_chip = {
.type = hwmon_chip,
.config = mv3310_hwmon_chip_config,
};
static u32 mv3310_hwmon_temp_config[] = {
HWMON_T_INPUT,
0,
};
static const struct hwmon_channel_info mv3310_hwmon_temp = {
.type = hwmon_temp,
.config = mv3310_hwmon_temp_config,
};
static const struct hwmon_channel_info * const mv3310_hwmon_info[] = {
&mv3310_hwmon_chip,
&mv3310_hwmon_temp,
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL),
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
NULL,
};