Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (pmbus) Do not set regulators_node for single-channel chips

Single-channel regulators do not need and should not have a "regulators"
node. We can not entirely remove it due to existing bindings. To solve the
problem for new drivers, provide additional macros PMBUS_REGULATOR_ONE_NODE
and PMBUS_REGULATOR_STEP_ONE_NODE and convert existing drivers to use those
macros. The exception is the ir38064 driver because its devicetree files
and its description do not require or use the nested regulators node.

Modify PMBUS_REGULATOR_STEP_ONE and PMBUS_REGULATOR_ONE to set the
regulators_node pointer to NULL.

Cc: Cedricjustine.Encarnacion@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20250322142602.560042-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

+20 -8
+1 -1
drivers/hwmon/pmbus/lm25066.c
··· 437 437 438 438 #if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR) 439 439 static const struct regulator_desc lm25066_reg_desc[] = { 440 - PMBUS_REGULATOR_ONE("vout"), 440 + PMBUS_REGULATOR_ONE_NODE("vout"), 441 441 }; 442 442 #endif 443 443
+2 -2
drivers/hwmon/pmbus/mpq7932.c
··· 51 51 }; 52 52 53 53 static const struct regulator_desc mpq7932_regulators_desc_one[] = { 54 - PMBUS_REGULATOR_STEP_ONE("buck", MPQ7932_N_VOLTAGES, 55 - MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN), 54 + PMBUS_REGULATOR_STEP_ONE_NODE("buck", MPQ7932_N_VOLTAGES, 55 + MPQ7932_UV_STEP, MPQ7932_BUCK_UV_MIN), 56 56 }; 57 57 #endif 58 58
+15 -3
drivers/hwmon/pmbus/pmbus.h
··· 509 509 510 510 #define PMBUS_REGULATOR(_name, _id) PMBUS_REGULATOR_STEP(_name, _id, 0, 0, 0) 511 511 512 - #define PMBUS_REGULATOR_STEP_ONE(_name, _voltages, _step, _min_uV) \ 512 + #define __PMBUS_REGULATOR_STEP_ONE(_name, _node, _voltages, _step, _min_uV) \ 513 513 { \ 514 514 .name = (_name), \ 515 515 .of_match = of_match_ptr(_name), \ 516 - .regulators_node = of_match_ptr("regulators"), \ 516 + .regulators_node = of_match_ptr(_node), \ 517 517 .ops = &pmbus_regulator_ops, \ 518 518 .type = REGULATOR_VOLTAGE, \ 519 519 .owner = THIS_MODULE, \ ··· 523 523 .init_cb = pmbus_regulator_init_cb, \ 524 524 } 525 525 526 - #define PMBUS_REGULATOR_ONE(_name) PMBUS_REGULATOR_STEP_ONE(_name, 0, 0, 0) 526 + /* 527 + * _NODE macros are defined for historic reasons and MUST NOT be used in new 528 + * drivers. 529 + */ 530 + #define PMBUS_REGULATOR_STEP_ONE_NODE(_name, _voltages, _step, _min_uV) \ 531 + __PMBUS_REGULATOR_STEP_ONE(_name, "regulators", _voltages, _step, _min_uV) 532 + 533 + #define PMBUS_REGULATOR_ONE_NODE(_name) PMBUS_REGULATOR_STEP_ONE_NODE(_name, 0, 0, 0) 534 + 535 + #define PMBUS_REGULATOR_STEP_ONE(_name, _voltages, _step, _min_uV) \ 536 + __PMBUS_REGULATOR_STEP_ONE(_name, NULL, _voltages, _step, _min_uV) 537 + 538 + #define PMBUS_REGULATOR_ONE(_name) PMBUS_REGULATOR_STEP_ONE(_name, 0, 0, 0) 527 539 528 540 /* Function declarations */ 529 541
+1 -1
drivers/hwmon/pmbus/tda38640.c
··· 15 15 #include "pmbus.h" 16 16 17 17 static const struct regulator_desc __maybe_unused tda38640_reg_desc[] = { 18 - PMBUS_REGULATOR_ONE("vout"), 18 + PMBUS_REGULATOR_ONE_NODE("vout"), 19 19 }; 20 20 21 21 struct tda38640_data {
+1 -1
drivers/hwmon/pmbus/tps25990.c
··· 333 333 334 334 #if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR) 335 335 static const struct regulator_desc tps25990_reg_desc[] = { 336 - PMBUS_REGULATOR_ONE("vout"), 336 + PMBUS_REGULATOR_ONE_NODE("vout"), 337 337 }; 338 338 #endif 339 339