static int __devinit db8500_regulator_probe(struct platform_device *pdev)
{
	struct db8500_regulator_init_data *db8500_init_pdata =
					dev_get_platdata(&pdev->dev);
	struct regulator_init_data *db8500_init_data =
		(struct regulator_init_data *) db8500_init_pdata->regulators;
	int i, err;

	prcmu_set_epod = db8500_init_pdata->set_epod;
	/* register all regulators */
	for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
		struct dbx500_regulator_info *info;
		struct regulator_init_data *init_data = &db8500_init_data[i];

		/* assign per-regulator data */
		info = &dbx500_regulator_info[i];
		info->dev = &pdev->dev;

		/* register with the regulator framework */
		info->rdev = regulator_register(&info->desc, &pdev->dev,
				init_data, info);
		if (IS_ERR(info->rdev)) {
			err = PTR_ERR(info->rdev);
			dev_err(&pdev->dev, "failed to register %s: err %i\n",
				info->desc.name, err);

			/* if failing, unregister all earlier regulators */
			while (--i >= 0) {
				info = &dbx500_regulator_info[i];
				regulator_unregister(info->rdev);
			}
			return err;
		}

		dev_dbg(rdev_get_dev(info->rdev),
			"regulator-%s-probed\n", info->desc.name);
	}
	err = ux500_regulator_debug_init(pdev,
					 dbx500_regulator_info,
					 ARRAY_SIZE(dbx500_regulator_info));

	return err;
}
Пример #2
0
static int db8500_regulator_probe(struct platform_device *pdev)
{
	struct regulator_init_data *db8500_init_data =
					dev_get_platdata(&pdev->dev);
	struct device_node *np = pdev->dev.of_node;
	int i, err;

	/* register all regulators */
	if (np) {
		err = of_regulator_match(&pdev->dev, np,
					db8500_regulator_matches,
					ARRAY_SIZE(db8500_regulator_matches));
		if (err < 0) {
			dev_err(&pdev->dev,
				"Error parsing regulator init data: %d\n", err);
			return err;
		}

		err = db8500_regulator_of_probe(pdev, np);
		if (err)
			return err;
	} else {
		for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
			err = db8500_regulator_register(pdev,
							&db8500_init_data[i],
							i, NULL);
			if (err)
				return err;
		}
	}

	err = ux500_regulator_debug_init(pdev,
					 dbx500_regulator_info,
					 ARRAY_SIZE(dbx500_regulator_info));
	return 0;
}