Skip to content

Conversation

sdivarci
Copy link

@sdivarci sdivarci commented Sep 26, 2025

PR Description

Add MAX31732 hwmod driver and documentation.

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

Add support for Analog Devices MAX31732, a five-channel temperature
monitor with per-channel alarms, calibration helpers, optional IRQ
handling, and MTP configuration.

Signed-off-by: Sinan Divarci <sinan.divarci@analog.com>
Add documentation for the Analog Devices MAX31732 temperature sensor driver
under Documentation/hwmon.

Signed-off-by: Sinan Divarci <sinan.divarci@analog.com>
Add device tree bindings for the Analog Devices MAX31732 temperature sensor
driver under Documentation/devicetree/bindings/hwmon/.

Signed-off-by: Sinan Divarci <sinan.divarci@analog.com>
Copy link
Collaborator

@nunojsa nunojsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sinan,

Just a first high level review. We first need to have this driver using modern hwmon API and have the userspace interface figured.

Also note that the expectation is for this to be first upstreamed (and accepted) before merging it in our tree


* All temperatures reported via sysfs are in milli-degree Celsius.
* ``stop`` halts conversions but does not power-cycle the part; use ``soft_por``
to restore all the registers to their default values.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this patch can typically be squashed with the one adding the driver

static const struct attribute_group mtp_attr_group = {
.name = "mtp",
.attrs = mtp_attrs,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above needs to be re-thought. The above is not the way to expose the hwmon interface. The below is what you need to be using (an example):

https://elixir.bootlin.com/linux/v6.17/source/drivers/hwmon/ltc4282.c#L1563

Then you need to look at the standard hwmon ABI:

https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface

and try to map as much as you can. The reason is that you'll have to justify very carefully why you need some non standard interface to be exposed to userspace. Often we don't really need to expose everything.

s32 ret;
u32 alarm_que;

if (fwnode_property_read_bool(dev_fwnode(dev), "adi,alarm1-interrupt-mode"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just as an hint for future versions of the patches you have device_property_read_bool(dev, ...). So no need for all of those dev_fwnode()


ret = devm_device_add_group(dev, &mtp_attr_group);
if (ret)
return dev_err_probe(dev, ret, "failed to create mtp sysfs group\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not how you should be adding attr groups. Needs to be done through the hwmon API (when registering the device)

if (reg_val == 0)
ret = regmap_set_bits(data->regmap, MAX31732_REG_CONF1, MAX31732_CONF1_STOP);
else
ret = regmap_clear_bits(data->regmap, MAX31732_REG_CONF1, MAX31732_CONF1_STOP);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the above you can use regmap_update_bits()

};

MODULE_DEVICE_TABLE(i2c, max31732_ids);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

{ .compatible = "adi,max31732", },
{ },
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

.class = I2C_CLASS_HWMON,
.driver = {
.name = "max31732-driver",
.of_match_table = of_match_ptr(max31732_of_match),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop of_match_ptr()

.driver = {
.name = "max31732-driver",
.of_match_table = of_match_ptr(max31732_of_match),
.pm = &max31732_pm_ops,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pm_sleep_ptr() together with DEFINE_SIMPLE_DEV_PM_OPS() and then no need of __maybe_unused

MODULE_DESCRIPTION("MAX31732 driver");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0");
MODULE_SOFTDEP("pre: regmap_i2c");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typically we dont really use the above two but I guess it does not harm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants