Re: [PATCH v5 3/3] regulator: add s2dos05 regulator support

From: Krzysztof Kozlowski
Date: Fri Sep 27 2024 - 04:55:31 EST


On Thu, Sep 26, 2024 at 12:47:32PM +0300, Dzmitry Sankouski wrote:
> +static int s2dos05_pmic_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> + struct of_regulator_match *rdata = NULL;
> + struct s2dos05_data *s2dos05;
> + struct regulator_config config = { };
> + unsigned int rdev_num = ARRAY_SIZE(regulators);
> + int i, ret;
> +
> + s2dos05 = devm_kzalloc(dev, sizeof(*s2dos05), GFP_KERNEL);
> + if (!s2dos05)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, s2dos05);
> +
> + rdata = devm_kcalloc(dev, rdev_num, sizeof(*rdata), GFP_KERNEL);
> + if (!rdata)
> + return -ENOMEM;
> +
> + for (i = 0; i < rdev_num; i++)
> + rdata[i].name = regulators[i].name;
> +
> + s2dos05->regmap = iodev->regmap_pmic;
> + s2dos05->dev = dev;
> + if (!dev->of_node)
> + dev->of_node = dev->parent->of_node;
> +
> + for (i = 0; i < rdev_num; i++) {
> + struct regulator_dev *regulator;
> +
> + config.init_data = rdata[i].init_data;
> + config.of_node = rdata[i].of_node;
> + config.dev = dev;
> + config.driver_data = s2dos05;
> + regulator = devm_regulator_register(&pdev->dev,
> + &regulators[i], &config);
> + if (IS_ERR(regulator)) {
> + ret = PTR_ERR(regulator);
> + dev_err(&pdev->dev, "regulator init failed for %d\n",
> + i);
> + }
> + }
> +
> + return ret;

ret is uninitialized. Please test your code with smatch and sparse.

Since I expect a new version, I will have a comment on the bindings as well.

Best regards,
Krzysztof