[PATCH RFC 1/2] hwmon: (sy7636a) fix races during probe of mfd subdevices

Andreas Kemnade
2025-09-20T11:43:43Z

If regulator subdevice is not ready early enough, devm_regulator_get will
get a dummy regulator device, not the real one needed from the regulator
subdevice, so defer probe in such case.
devm_regulator_get_optional returns an error in that case.

That fixes things, but looks odd, therefore RFC.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
drivers/hwmon/sy7636a-hwmon.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
index ed110884786b..e83d0e50c735 100644
--- a/drivers/hwmon/sy7636a-hwmon.c
+++ b/drivers/hwmon/sy7636a-hwmon.c
@@ -73,9 +73,9 @@ static int sy7636a_sensor_probe(struct platform_device *pdev)
if (!regmap)
return -EPROBE_DEFER;

- regulator = devm_regulator_get(&pdev->dev, "vcom");
- if (IS_ERR(regulator))
- return PTR_ERR(regulator);
+ regulator = devm_regulator_get_optional(&pdev->dev, "vcom");
+ if (IS_ERR_OR_NULL(regulator))
+ return -EPROBE_DEFER;

err = regulator_enable(regulator);
if (err)
--
2.47.3