Re: [PATCH net-next 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events
From: Jakub Kicinski
Date: Mon Jul 27 2026 - 20:21:38 EST
On Tue, 21 Jul 2026 15:15:40 -0700 Zinc Lim wrote:
> +void fbnic_hwmon_notify_event(struct fbnic_dev *fbd, int id, long val)
> +{
> + enum hwmon_sensor_types type;
> + struct device *hwmon;
> + s32 attr = -1;
> +
> + switch (id) {
> + case FBNIC_SENSOR_TEMP:
> + type = hwmon_temp;
> +
> + if (val <= fbd->fw_cap.temp.min)
> + attr = hwmon_temp_min_alarm;
> + else if (val >= fbd->fw_cap.temp.crit)
> + attr = hwmon_temp_crit_alarm;
> + else if (val >= fbd->fw_cap.temp.max)
> + attr = hwmon_temp_max_alarm;
> +
> + break;
> + case FBNIC_SENSOR_VOLTAGE:
> + type = hwmon_in;
> +
> + if (val <= fbd->fw_cap.volt.min)
> + attr = hwmon_in_min_alarm;
> + else if (val >= fbd->fw_cap.volt.max)
> + attr = hwmon_in_max_alarm;
> +
> + break;
> + default:
> + return;
> + }
> +
> + /* Pair with WRITE_ONCE() in fbnic_hwmon_unregister(). Skip the
> + * notification if hwmon failed to register or has already been torn
> + * down.
> + */
> + hwmon = READ_ONCE(fbd->hwmon);
> + if (attr >= 0 && hwmon)
> + hwmon_notify_event(hwmon, type, attr, 0);
> }
We need a
if (!IS_REACHABLE(CONFIG_HWMON))
return;
in this function, so that compiler can eliminate the
hwmon_notify_event() call _completely_ if HWMON is a module
and the driver is built into the main kernel image.
--
pw-bot: cr