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

Commit 854f73ec authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

regulator: s5m8767: Remove max_vol parameter from s5m8767_convert_voltage_to_sel



It looks pointless to pass max_vol to s5m8767_convert_voltage_to_sel().
Compare selected voltage to desc->max is enough to ensure selected voltage
is in supported range.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 30510194
Loading
Loading
Loading
Loading
+10 −23
Original line number Original line Diff line number Diff line
@@ -323,16 +323,15 @@ static int s5m8767_get_voltage_sel(struct regulator_dev *rdev)
	return val;
	return val;
}
}


static int s5m8767_convert_voltage_to_sel(
static int s5m8767_convert_voltage_to_sel(const struct sec_voltage_desc *desc,
		const struct sec_voltage_desc *desc,
					  int min_vol)
		int min_vol, int max_vol)
{
{
	int selector = 0;
	int selector = 0;


	if (desc == NULL)
	if (desc == NULL)
		return -EINVAL;
		return -EINVAL;


	if (max_vol < desc->min || min_vol > desc->max)
	if (min_vol > desc->max)
		return -EINVAL;
		return -EINVAL;


	if (min_vol < desc->min)
	if (min_vol < desc->min)
@@ -340,7 +339,7 @@ static int s5m8767_convert_voltage_to_sel(


	selector = DIV_ROUND_UP(min_vol - desc->min, desc->step);
	selector = DIV_ROUND_UP(min_vol - desc->min, desc->step);


	if (desc->min + desc->step * selector > max_vol)
	if (desc->min + desc->step * selector > desc->max)
		return -EINVAL;
		return -EINVAL;


	return selector;
	return selector;
@@ -577,23 +576,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
	s5m8767->opmode = pdata->opmode;
	s5m8767->opmode = pdata->opmode;


	buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
	buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
						pdata->buck2_init,
						   pdata->buck2_init);
						pdata->buck2_init +
						buck_voltage_val2.step);


	sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init);
	sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init);


	buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
	buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
						pdata->buck3_init,
						   pdata->buck3_init);
						pdata->buck3_init +
						buck_voltage_val2.step);


	sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init);
	sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init);


	buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
	buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2,
						pdata->buck4_init,
						   pdata->buck4_init);
						pdata->buck4_init +
						buck_voltage_val2.step);


	sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init);
	sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init);


@@ -602,27 +595,21 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
			s5m8767->buck2_vol[i] =
			s5m8767->buck2_vol[i] =
				s5m8767_convert_voltage_to_sel(
				s5m8767_convert_voltage_to_sel(
						&buck_voltage_val2,
						&buck_voltage_val2,
						pdata->buck2_voltage[i],
						pdata->buck2_voltage[i]);
						pdata->buck2_voltage[i] +
						buck_voltage_val2.step);
		}
		}


		if (s5m8767->buck3_gpiodvs) {
		if (s5m8767->buck3_gpiodvs) {
			s5m8767->buck3_vol[i] =
			s5m8767->buck3_vol[i] =
				s5m8767_convert_voltage_to_sel(
				s5m8767_convert_voltage_to_sel(
						&buck_voltage_val2,
						&buck_voltage_val2,
						pdata->buck3_voltage[i],
						pdata->buck3_voltage[i]);
						pdata->buck3_voltage[i] +
						buck_voltage_val2.step);
		}
		}


		if (s5m8767->buck4_gpiodvs) {
		if (s5m8767->buck4_gpiodvs) {
			s5m8767->buck4_vol[i] =
			s5m8767->buck4_vol[i] =
				s5m8767_convert_voltage_to_sel(
				s5m8767_convert_voltage_to_sel(
						&buck_voltage_val2,
						&buck_voltage_val2,
						pdata->buck4_voltage[i],
						pdata->buck4_voltage[i]);
						pdata->buck4_voltage[i] +
						buck_voltage_val2.step);
		}
		}
	}
	}