diff options
author | Guodong Xu <guodong.xu@linaro.org> | 2014-08-13 07:33:38 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-08-16 17:55:42 -0400 |
commit | 272e2315fac3bfca0edfa3252b8a643c425602af (patch) | |
tree | b77a640434ef12dbd381c2f7d712d567cf73ea18 | |
parent | 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff) |
regulator: core: add const qualifier to ops in struct regulator_desc
struct regulator_ops *ops is a member in struct regulator_desc, which gets
its value from individual regulator driver upon regulator_register() and
is used by regulator core APIs. It's not allowed for regulator core to
modify any of these callbacks in *ops. Add 'const' qualifier to enforce that.
Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/core.c | 24 | ||||
-rw-r--r-- | include/linux/regulator/driver.h | 2 |
2 files changed, 13 insertions, 13 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a3c3785901f5..052e7f1f011d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -839,7 +839,7 @@ static void print_constraints(struct regulator_dev *rdev) | |||
839 | static int machine_constraints_voltage(struct regulator_dev *rdev, | 839 | static int machine_constraints_voltage(struct regulator_dev *rdev, |
840 | struct regulation_constraints *constraints) | 840 | struct regulation_constraints *constraints) |
841 | { | 841 | { |
842 | struct regulator_ops *ops = rdev->desc->ops; | 842 | const struct regulator_ops *ops = rdev->desc->ops; |
843 | int ret; | 843 | int ret; |
844 | 844 | ||
845 | /* do we need to apply the constraint voltage */ | 845 | /* do we need to apply the constraint voltage */ |
@@ -938,7 +938,7 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, | |||
938 | static int machine_constraints_current(struct regulator_dev *rdev, | 938 | static int machine_constraints_current(struct regulator_dev *rdev, |
939 | struct regulation_constraints *constraints) | 939 | struct regulation_constraints *constraints) |
940 | { | 940 | { |
941 | struct regulator_ops *ops = rdev->desc->ops; | 941 | const struct regulator_ops *ops = rdev->desc->ops; |
942 | int ret; | 942 | int ret; |
943 | 943 | ||
944 | if (!constraints->min_uA && !constraints->max_uA) | 944 | if (!constraints->min_uA && !constraints->max_uA) |
@@ -982,7 +982,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, | |||
982 | const struct regulation_constraints *constraints) | 982 | const struct regulation_constraints *constraints) |
983 | { | 983 | { |
984 | int ret = 0; | 984 | int ret = 0; |
985 | struct regulator_ops *ops = rdev->desc->ops; | 985 | const struct regulator_ops *ops = rdev->desc->ops; |
986 | 986 | ||
987 | if (constraints) | 987 | if (constraints) |
988 | rdev->constraints = kmemdup(constraints, sizeof(*constraints), | 988 | rdev->constraints = kmemdup(constraints, sizeof(*constraints), |
@@ -2208,9 +2208,9 @@ EXPORT_SYMBOL_GPL(regulator_count_voltages); | |||
2208 | */ | 2208 | */ |
2209 | int regulator_list_voltage(struct regulator *regulator, unsigned selector) | 2209 | int regulator_list_voltage(struct regulator *regulator, unsigned selector) |
2210 | { | 2210 | { |
2211 | struct regulator_dev *rdev = regulator->rdev; | 2211 | struct regulator_dev *rdev = regulator->rdev; |
2212 | struct regulator_ops *ops = rdev->desc->ops; | 2212 | const struct regulator_ops *ops = rdev->desc->ops; |
2213 | int ret; | 2213 | int ret; |
2214 | 2214 | ||
2215 | if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector) | 2215 | if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector) |
2216 | return rdev->desc->fixed_uV; | 2216 | return rdev->desc->fixed_uV; |
@@ -2572,8 +2572,8 @@ EXPORT_SYMBOL_GPL(regulator_set_voltage); | |||
2572 | int regulator_set_voltage_time(struct regulator *regulator, | 2572 | int regulator_set_voltage_time(struct regulator *regulator, |
2573 | int old_uV, int new_uV) | 2573 | int old_uV, int new_uV) |
2574 | { | 2574 | { |
2575 | struct regulator_dev *rdev = regulator->rdev; | 2575 | struct regulator_dev *rdev = regulator->rdev; |
2576 | struct regulator_ops *ops = rdev->desc->ops; | 2576 | const struct regulator_ops *ops = rdev->desc->ops; |
2577 | int old_sel = -1; | 2577 | int old_sel = -1; |
2578 | int new_sel = -1; | 2578 | int new_sel = -1; |
2579 | int voltage; | 2579 | int voltage; |
@@ -3336,9 +3336,9 @@ EXPORT_SYMBOL_GPL(regulator_mode_to_status); | |||
3336 | */ | 3336 | */ |
3337 | static int add_regulator_attributes(struct regulator_dev *rdev) | 3337 | static int add_regulator_attributes(struct regulator_dev *rdev) |
3338 | { | 3338 | { |
3339 | struct device *dev = &rdev->dev; | 3339 | struct device *dev = &rdev->dev; |
3340 | struct regulator_ops *ops = rdev->desc->ops; | 3340 | const struct regulator_ops *ops = rdev->desc->ops; |
3341 | int status = 0; | 3341 | int status = 0; |
3342 | 3342 | ||
3343 | /* some attributes need specific methods to be displayed */ | 3343 | /* some attributes need specific methods to be displayed */ |
3344 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || | 3344 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || |
@@ -3905,7 +3905,7 @@ core_initcall(regulator_init); | |||
3905 | static int __init regulator_init_complete(void) | 3905 | static int __init regulator_init_complete(void) |
3906 | { | 3906 | { |
3907 | struct regulator_dev *rdev; | 3907 | struct regulator_dev *rdev; |
3908 | struct regulator_ops *ops; | 3908 | const struct regulator_ops *ops; |
3909 | struct regulation_constraints *c; | 3909 | struct regulation_constraints *c; |
3910 | int enabled, ret; | 3910 | int enabled, ret; |
3911 | 3911 | ||
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index bbe03a1924c0..4b628139a9cb 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -245,7 +245,7 @@ struct regulator_desc { | |||
245 | int id; | 245 | int id; |
246 | bool continuous_voltage_range; | 246 | bool continuous_voltage_range; |
247 | unsigned n_voltages; | 247 | unsigned n_voltages; |
248 | struct regulator_ops *ops; | 248 | const struct regulator_ops *ops; |
249 | int irq; | 249 | int irq; |
250 | enum regulator_type type; | 250 | enum regulator_type type; |
251 | struct module *owner; | 251 | struct module *owner; |