Skip to content

devm_hwmon_device_register_with_info()

Purpose

Registers a hardware monitoring device using standard hwmon channel information with device-managed cleanup.

#include <linux/hwmon.h>

Prototype

struct device *devm_hwmon_device_register_with_info(struct device *dev,
                                                    const char *name,
                                                    void *drvdata,
                                                    const struct hwmon_chip_info *info,
                                                    const struct attribute_group **extra_groups);

Parameters

  • dev: parent device.
  • name: hwmon device name.
  • drvdata: private driver data passed to hwmon callbacks.
  • info: hwmon chip/channel description.
  • extra_groups: optional extra sysfs attribute groups.

Return Value

  • Success: pointer to the registered hwmon device.
  • Failure: error pointer; check with IS_ERR().

Minimal Example

hwmon = devm_hwmon_device_register_with_info(dev, "mytemp", priv,
                                             &mytemp_chip_info, NULL);
if (IS_ERR(hwmon))
    return PTR_ERR(hwmon);

Common Pitfalls

  • Return values must use hwmon standard units.
  • Use standard channel attributes when possible instead of custom sysfs files.
  • Validate whether the device belongs in hwmon or IIO based on data model and sampling behavior.