On 9/13/24 06:28, Andrew Lunn wrote:
+static int fbnic_hwmon_sensor_id(enum hwmon_sensor_types type)
+{
+ if (type == hwmon_temp)
+ return FBNIC_SENSOR_TEMP;
+ if (type == hwmon_in)
+ return FBNIC_SENSOR_VOLTAGE;
+
+ return -EOPNOTSUPP;
+}
+static int fbnic_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
+ u32 attr, int channel, long *val)
+{
+ struct fbnic_dev *fbd = dev_get_drvdata(dev);
+ const struct fbnic_mac *mac = fbd->mac;
+ int id;
+
+ id = fbnic_hwmon_sensor_id(type);
+ if (id < 0)
+ return -EOPNOTSUPP;
fbnic_hwmon_sensor_id() itself returns EOPNOTSUPP, so just use it.
+void fbnic_hwmon_register(struct fbnic_dev *fbd)
+{
+ if (!IS_REACHABLE(CONFIG_HWMON))
+ return;
+
+ fbd->hwmon = hwmon_device_register_with_info(fbd->dev, "fbnic",
+ fbd, &fbnic_chip_info,
+ NULL);
+ if (IS_ERR(fbd->hwmon)) {
+ dev_err(fbd->dev,
+ "Cannot register hwmon device %pe, aborting\n",
+ fbd->hwmon);
aborting is probably the wrong word, because you keep going
independent of it working or not.
I have not seen the original patch, and it doesn't seem to be available
on the networking mailing list, so I can not really comment on the patch
as a whole. For hwmon drivers in drivers/hwmon, I don't accept patches
with dev_err() which is then ignored ... because ignoring the error
means that it is not really an error. This should be dev_warn()
or better dev_notice().
Guenter