static int tps65217_regulator_probe(struct platform_device *pdev) { struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); struct tps65217_board *pdata = dev_get_platdata(tps->dev); struct regulator_dev *rdev; struct regulator_config config = { }; int i; if (tps->dev->of_node) pdata = tps65217_parse_dt(pdev); if (!pdata) { dev_err(&pdev->dev, "Platform data not found\n"); return -EINVAL; } if (tps65217_chip_id(tps) != TPS65217) { dev_err(&pdev->dev, "Invalid tps chip version\n"); return -ENODEV; } platform_set_drvdata(pdev, tps); for (i = 0; i < TPS65217_NUM_REGULATOR; i++) { /* Register the regulators */ config.dev = tps->dev; config.init_data = pdata->tps65217_init_data[i]; config.driver_data = tps; config.regmap = tps->regmap; if (tps->dev->of_node) config.of_node = pdata->of_node[i]; rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { dev_err(tps->dev, "failed to register %s regulator\n", pdev->name); return PTR_ERR(rdev); } } return 0; }
static int tps65217_regulator_probe(struct platform_device *pdev) { struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); struct tps65217_board *pdata = dev_get_platdata(tps->dev); struct regulator_init_data *reg_data; struct regulator_dev *rdev; struct regulator_config config = { }; int i, ret; if (tps->dev->of_node) pdata = tps65217_parse_dt(pdev); if (!pdata) { dev_err(&pdev->dev, "Platform data not found\n"); return -EINVAL; } if (tps65217_chip_id(tps) != TPS65217) { dev_err(&pdev->dev, "Invalid tps chip version\n"); return -ENODEV; } platform_set_drvdata(pdev, tps); for (i = 0; i < TPS65217_NUM_REGULATOR; i++) { reg_data = pdata->tps65217_init_data[i]; /* * Regulator API handles empty constraints but not NULL * constraints */ if (!reg_data) continue; /* Register the regulators */ config.dev = tps->dev; config.init_data = reg_data; config.driver_data = tps; config.regmap = tps->regmap; if (tps->dev->of_node) config.of_node = pdata->of_node[i]; rdev = regulator_register(®ulators[i], &config); if (IS_ERR(rdev)) { dev_err(tps->dev, "failed to register %s regulator\n", pdev->name); ret = PTR_ERR(rdev); goto err_unregister_regulator; } /* Save regulator for cleanup */ tps->rdev[i] = rdev; } return 0; err_unregister_regulator: while (--i >= 0) regulator_unregister(tps->rdev[i]); return ret; }