Commit 39f5460d authored by Guodong Xu's avatar Guodong Xu Committed by Mark Brown

regulator: core: add const to regulator_ops and fix build error in mc13892

Commit 272e2315 ("regulator: core: add const qualifier to ops in
struct regulator_desc") introduced const qualifier to ops in regulator_desc.

This patch adds 'const' to regulator_ops vars in newly added core APIs
for v3.17-rc1:
 - regulator_get_hardware_vsel_register()
 - regulator_list_hardware_vsel()

This patch also fix a build error in mc13892-regulator.c due to const
regulator_desc.ops. Modification of regulator_desc.ops' member fields is not
allowed.
Signed-off-by: default avatarGuodong Xu <guodong.xu@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 716845eb
...@@ -2308,7 +2308,7 @@ int regulator_get_hardware_vsel_register(struct regulator *regulator, ...@@ -2308,7 +2308,7 @@ int regulator_get_hardware_vsel_register(struct regulator *regulator,
unsigned *vsel_mask) unsigned *vsel_mask)
{ {
struct regulator_dev *rdev = regulator->rdev; struct regulator_dev *rdev = regulator->rdev;
struct regulator_ops *ops = rdev->desc->ops; const struct regulator_ops *ops = rdev->desc->ops;
if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap) if (ops->set_voltage_sel != regulator_set_voltage_sel_regmap)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -2335,7 +2335,7 @@ int regulator_list_hardware_vsel(struct regulator *regulator, ...@@ -2335,7 +2335,7 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
unsigned selector) unsigned selector)
{ {
struct regulator_dev *rdev = regulator->rdev; struct regulator_dev *rdev = regulator->rdev;
struct regulator_ops *ops = rdev->desc->ops; const struct regulator_ops *ops = rdev->desc->ops;
if (selector >= rdev->desc->n_voltages) if (selector >= rdev->desc->n_voltages)
return -EINVAL; return -EINVAL;
......
...@@ -526,6 +526,7 @@ static unsigned int mc13892_vcam_get_mode(struct regulator_dev *rdev) ...@@ -526,6 +526,7 @@ static unsigned int mc13892_vcam_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_NORMAL;
} }
static struct regulator_ops mc13892_vcam_ops;
static int mc13892_regulator_probe(struct platform_device *pdev) static int mc13892_regulator_probe(struct platform_device *pdev)
{ {
...@@ -582,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev) ...@@ -582,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
} }
mc13xxx_unlock(mc13892); mc13xxx_unlock(mc13892);
mc13892_regulators[MC13892_VCAM].desc.ops->set_mode /* update mc13892_vcam ops */
= mc13892_vcam_set_mode; memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
mc13892_regulators[MC13892_VCAM].desc.ops->get_mode sizeof(struct regulator_ops));
= mc13892_vcam_get_mode; mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators, mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
ARRAY_SIZE(mc13892_regulators)); ARRAY_SIZE(mc13892_regulators));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment