Skip to content

Commit 0b3c04c

Browse files
committed
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>
1 parent 629cf8f commit 0b3c04c

5 files changed

Lines changed: 20 additions & 8 deletions

File tree

drivers/hwmon/pmbus/lm25066.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,
437437

438438
#if IS_ENABLED(CONFIG_SENSORS_LM25066_REGULATOR)
439439
static const struct regulator_desc lm25066_reg_desc[] = {
440-
PMBUS_REGULATOR_ONE("vout"),
440+
PMBUS_REGULATOR_ONE_NODE("vout"),
441441
};
442442
#endif
443443

drivers/hwmon/pmbus/mpq7932.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static const struct regulator_desc mpq7932_regulators_desc[] = {
5151
};
5252

5353
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),
5656
};
5757
#endif
5858

drivers/hwmon/pmbus/pmbus.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,11 @@ int pmbus_regulator_init_cb(struct regulator_dev *rdev,
509509

510510
#define PMBUS_REGULATOR(_name, _id) PMBUS_REGULATOR_STEP(_name, _id, 0, 0, 0)
511511

512-
#define PMBUS_REGULATOR_STEP_ONE(_name, _voltages, _step, _min_uV) \
512+
#define __PMBUS_REGULATOR_STEP_ONE(_name, _node, _voltages, _step, _min_uV) \
513513
{ \
514514
.name = (_name), \
515515
.of_match = of_match_ptr(_name), \
516-
.regulators_node = of_match_ptr("regulators"), \
516+
.regulators_node = of_match_ptr(_node), \
517517
.ops = &pmbus_regulator_ops, \
518518
.type = REGULATOR_VOLTAGE, \
519519
.owner = THIS_MODULE, \
@@ -523,7 +523,19 @@ int pmbus_regulator_init_cb(struct regulator_dev *rdev,
523523
.init_cb = pmbus_regulator_init_cb, \
524524
}
525525

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)
527539

528540
/* Function declarations */
529541

drivers/hwmon/pmbus/tda38640.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "pmbus.h"
1616

1717
static const struct regulator_desc __maybe_unused tda38640_reg_desc[] = {
18-
PMBUS_REGULATOR_ONE("vout"),
18+
PMBUS_REGULATOR_ONE_NODE("vout"),
1919
};
2020

2121
struct tda38640_data {

drivers/hwmon/pmbus/tps25990.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static int tps25990_write_byte_data(struct i2c_client *client,
333333

334334
#if IS_ENABLED(CONFIG_SENSORS_TPS25990_REGULATOR)
335335
static const struct regulator_desc tps25990_reg_desc[] = {
336-
PMBUS_REGULATOR_ONE("vout"),
336+
PMBUS_REGULATOR_ONE_NODE("vout"),
337337
};
338338
#endif
339339

0 commit comments

Comments
 (0)