Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c172708d authored by Mark Brown's avatar Mark Brown
Browse files

regulator: core: Use a struct to pass in regulator runtime configuration



Rather than adding new arguments to regulator_register() every time we
want to add a new bit of dynamic information at runtime change the function
to take these via a struct. By doing this we avoid needing to do further
changes like the recent addition of device tree support which required each
regulator driver to be updated to take an additional parameter.

The regulator_desc which should (mostly) be static data is still passed
separately as most drivers are able to configure this statically at build
time.

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 1474e4db
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -365,6 +365,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
	struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
	struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
	struct pm8607_regulator_info *info = NULL;
	struct pm8607_regulator_info *info = NULL;
	struct regulator_init_data *pdata = pdev->dev.platform_data;
	struct regulator_init_data *pdata = pdev->dev.platform_data;
	struct regulator_config config = { };
	struct resource *res;
	struct resource *res;
	int i;
	int i;


@@ -390,9 +391,12 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
	if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
	if ((i == PM8607_ID_BUCK3) && info->chip->buck3_double)
		info->slope_double = 1;
		info->slope_double = 1;


	config.dev = &pdev->dev;
	config.init_data = pdata;
	config.driver_data = info;

	/* replace driver_data with info */
	/* replace driver_data with info */
	info->regulator = regulator_register(&info->desc, &pdev->dev,
	info->regulator = regulator_register(&info->desc, &config);
					     pdata, info, NULL);
	if (IS_ERR(info->regulator)) {
	if (IS_ERR(info->regulator)) {
		dev_err(&pdev->dev, "failed to register regulator %s\n",
		dev_err(&pdev->dev, "failed to register regulator %s\n",
			info->desc.name);
			info->desc.name);
+6 −2
Original line number Original line Diff line number Diff line
@@ -178,6 +178,7 @@ static struct aat2870_regulator *aat2870_get_regulator(int id)
static int aat2870_regulator_probe(struct platform_device *pdev)
static int aat2870_regulator_probe(struct platform_device *pdev)
{
{
	struct aat2870_regulator *ri;
	struct aat2870_regulator *ri;
	struct regulator_config config = { 0 };
	struct regulator_dev *rdev;
	struct regulator_dev *rdev;


	ri = aat2870_get_regulator(pdev->id);
	ri = aat2870_get_regulator(pdev->id);
@@ -187,8 +188,11 @@ static int aat2870_regulator_probe(struct platform_device *pdev)
	}
	}
	ri->aat2870 = dev_get_drvdata(pdev->dev.parent);
	ri->aat2870 = dev_get_drvdata(pdev->dev.parent);


	rdev = regulator_register(&ri->desc, &pdev->dev,
	config.dev = &pdev->dev;
				  pdev->dev.platform_data, ri, NULL);
	config.driver_data = ri;
	config.init_data = pdev->dev.platform_data;

	rdev = regulator_register(&ri->desc, &config);
	if (IS_ERR(rdev)) {
	if (IS_ERR(rdev)) {
		dev_err(&pdev->dev, "Failed to register regulator %s\n",
		dev_err(&pdev->dev, "Failed to register regulator %s\n",
			ri->desc.name);
			ri->desc.name);
+6 −5
Original line number Original line Diff line number Diff line
@@ -574,6 +574,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
{
{
	struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
	struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
	struct regulator_config config = { };
	int err = 0;
	int err = 0;
	u8 data;
	u8 data;
	int i;
	int i;
@@ -619,15 +620,15 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
		reg->dev = &pdev->dev;
		reg->dev = &pdev->dev;
		reg->plfdata = plfdata;
		reg->plfdata = plfdata;


		config.dev = &pdev->dev;
		config.driver_data = reg;
		config.init_data = &plfdata->reg_constraints[i];

		/*
		/*
		 * Register the regulator, pass around
		 * Register the regulator, pass around
		 * the ab3100_regulator struct
		 * the ab3100_regulator struct
		 */
		 */
		rdev = regulator_register(&ab3100_regulator_desc[i],
		rdev = regulator_register(&ab3100_regulator_desc[i], &config);
					  &pdev->dev,
					  &plfdata->reg_constraints[i],
					  reg, NULL);

		if (IS_ERR(rdev)) {
		if (IS_ERR(rdev)) {
			err = PTR_ERR(rdev);
			err = PTR_ERR(rdev);
			dev_err(&pdev->dev,
			dev_err(&pdev->dev,
+6 −2
Original line number Original line Diff line number Diff line
@@ -712,6 +712,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
{
{
	struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
	struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
	struct ab8500_platform_data *pdata;
	struct ab8500_platform_data *pdata;
	struct regulator_config config = { };
	int i, err;
	int i, err;


	if (!ab8500) {
	if (!ab8500) {
@@ -779,6 +780,10 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
		info = &ab8500_regulator_info[i];
		info = &ab8500_regulator_info[i];
		info->dev = &pdev->dev;
		info->dev = &pdev->dev;


		config->dev = &pdev->dev;
		config->init_data = &pdata->regulator[i];
		config->driver_data = info;

		/* fix for hardware before ab8500v2.0 */
		/* fix for hardware before ab8500v2.0 */
		if (abx500_get_chip_id(info->dev) < 0x20) {
		if (abx500_get_chip_id(info->dev) < 0x20) {
			if (info->desc.id == AB8500_LDO_AUX3) {
			if (info->desc.id == AB8500_LDO_AUX3) {
@@ -792,8 +797,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
		}
		}


		/* register regulator with framework */
		/* register regulator with framework */
		info->regulator = regulator_register(&info->desc, &pdev->dev,
		info->regulator = regulator_register(&info->desc, &config);
				&pdata->regulator[i], info, NULL);
		if (IS_ERR(info->regulator)) {
		if (IS_ERR(info->regulator)) {
			err = PTR_ERR(info->regulator);
			err = PTR_ERR(info->regulator);
			dev_err(&pdev->dev, "failed to register regulator %s\n",
			dev_err(&pdev->dev, "failed to register regulator %s\n",
+6 −2
Original line number Original line Diff line number Diff line
@@ -212,6 +212,7 @@ static int __devinit ad5398_probe(struct i2c_client *client,
				const struct i2c_device_id *id)
				const struct i2c_device_id *id)
{
{
	struct regulator_init_data *init_data = client->dev.platform_data;
	struct regulator_init_data *init_data = client->dev.platform_data;
	struct regulator_config config = { };
	struct ad5398_chip_info *chip;
	struct ad5398_chip_info *chip;
	const struct ad5398_current_data_format *df =
	const struct ad5398_current_data_format *df =
			(struct ad5398_current_data_format *)id->driver_data;
			(struct ad5398_current_data_format *)id->driver_data;
@@ -224,6 +225,10 @@ static int __devinit ad5398_probe(struct i2c_client *client,
	if (!chip)
	if (!chip)
		return -ENOMEM;
		return -ENOMEM;


	config.dev = &client->dev;
	config.init_data = init_data;
	config.driver_data = chip;

	chip->client = client;
	chip->client = client;


	chip->min_uA = df->min_uA;
	chip->min_uA = df->min_uA;
@@ -232,8 +237,7 @@ static int __devinit ad5398_probe(struct i2c_client *client,
	chip->current_offset = df->current_offset;
	chip->current_offset = df->current_offset;
	chip->current_mask = (chip->current_level - 1) << chip->current_offset;
	chip->current_mask = (chip->current_level - 1) << chip->current_offset;


	chip->rdev = regulator_register(&ad5398_reg, &client->dev,
	chip->rdev = regulator_register(&ad5398_reg, &config);
					init_data, chip, NULL);
	if (IS_ERR(chip->rdev)) {
	if (IS_ERR(chip->rdev)) {
		ret = PTR_ERR(chip->rdev);
		ret = PTR_ERR(chip->rdev);
		dev_err(&client->dev, "failed to register %s %s\n",
		dev_err(&client->dev, "failed to register %s %s\n",
Loading