Skip to contentSkip to conversation

hwmon: (pmbus/ltc4286) support building the sensor as a module

PATCH Applied Pengpeng Hou 3 participants 3 messages Dec 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (pmbus/ltc4286) support building the sensor as a module

With PMBUS=m, Kbuild descends into pmbus/ for modules. An ltc4286 object placed in obj-y by the boolean sensor option is not part of that build.

Make the sensor option tristate. Export its existing OF match table as
well: an I2C client instantiated from a device tree can produce an OF modalias rather than an i2c modalias. Keep the existing I2C IDs for other clients.

The issue was found by our static-analysis tool and manually reviewed.

Fixes 0c459759ca97 ("hwmon: (pmbus) Add ltc4286 driver")

---
The original patch was prepared with Gemini. Codex assisted with this review and revision (Assisted-by: gpt 5).
Built ltc4286.o on x86-64 with GCC 11.4 and W=1 (CONFIG_PMBUS=m, CONFIG_SENSORS_LTC4286=m). The object contains both I2C and OF device-table symbols. No runtime or hardware test was performed.

 drivers/hwmon/pmbus/Kconfig   | 5 ++++-
 drivers/hwmon/pmbus/ltc4286.c | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/Kconfig +4 -1
index fd6641316454f00eef8d7b7502da9d76c7ed2c4e..6a4a1ab257deaad79da021115fab83b990803358 100644
@@ -320,7 +320,7 @@ config SENSORS_LTC3815
 	  be called ltc3815.
 
 config SENSORS_LTC4286
-	bool "Analog Devices LTC4286"
+	tristate "Analog Devices LTC4286"
 	help
 	  LTC4286 is an integrated solution for hot swap applications that
 	  allows a board to be safely inserted and removed from a live
@@ -329,6 +329,9 @@ config SENSORS_LTC4286
 	  If you say yes here you get hardware monitoring support for Analog
 	  Devices LTC4286.
 
+	  This driver can also be built as a module. If so, the module will
+	  be called ltc4286.
+
 config SENSORS_LX1308
 	tristate "Luxshare LX1308 DC/DC Power Module"
 	help
drivers/hwmon/pmbus/ltc4286.c +1 -0
index ea2f9a5a4b24973b577a2292ce76ab70e4430cdc..7e6c2e911d1647758d01a4931ca1b75b18dad43a 100644
@@ -246,6 +246,7 @@ static const struct of_device_id ltc4286_of_match[] = {
 	{ .compatible = "lltc,ltc4287" },
 	{}
 };
+MODULE_DEVICE_TABLE(of, ltc4286_of_match);
 
 static struct i2c_driver ltc4286_driver = {
 	.driver = {

base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106

#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

With PMBUS=m, Kbuild descends into pmbus/ for modules. An ltc4286 object placed in obj-y by the boolean sensor option is not part of that build.

Make the sensor option tristate. Export its existing OF match table as
well: an I2C client instantiated from a device tree can produce an OF modalias rather than an i2c modalias. Keep the existing I2C IDs for other clients.

Quoted 4 lines

The issue was found by our static-analysis tool and manually reviewed.

Fixes 0c459759ca97 ("hwmon: (pmbus) Add ltc4286 driver")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Applied
#2 lore raw
In reply to Pengpeng Hou
Quoted 8 lines · Pengpeng Hou

With PMBUS=m, Kbuild descends into pmbus/ for modules. An ltc4286 object placed in obj-y by the boolean sensor option is not part of that build.

Make the sensor option tristate. Export its existing OF match table as
well: an I2C client instantiated from a device tree can produce an OF modalias rather than an i2c modalias. Keep the existing I2C IDs for other clients.

Quoted 4 lines

The issue was found by our static-analysis tool and manually reviewed.

Fixes 0c459759ca97 ("hwmon: (pmbus) Add ltc4286 driver")

Applied.

Thanks,
Guenter