Commit eeb1b235 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: vexpress: Get rid of struct vexpress_regulator

The *regdev and *regmap can be replaced by local variables in probe().
Only desc of struct vexpress_regulator is really need, so just use
struct regulator_desc directly and remove struct vexpress_regulator.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent fb9bf5c8
...@@ -23,17 +23,10 @@ ...@@ -23,17 +23,10 @@
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/vexpress.h> #include <linux/vexpress.h>
struct vexpress_regulator {
struct regulator_desc desc;
struct regulator_dev *regdev;
struct regmap *regmap;
};
static int vexpress_regulator_get_voltage(struct regulator_dev *regdev) static int vexpress_regulator_get_voltage(struct regulator_dev *regdev)
{ {
struct vexpress_regulator *reg = rdev_get_drvdata(regdev); unsigned int uV;
u32 uV; int err = regmap_read(regdev->regmap, 0, &uV);
int err = regmap_read(reg->regmap, 0, &uV);
return err ? err : uV; return err ? err : uV;
} }
...@@ -41,9 +34,7 @@ static int vexpress_regulator_get_voltage(struct regulator_dev *regdev) ...@@ -41,9 +34,7 @@ static int vexpress_regulator_get_voltage(struct regulator_dev *regdev)
static int vexpress_regulator_set_voltage(struct regulator_dev *regdev, static int vexpress_regulator_set_voltage(struct regulator_dev *regdev,
int min_uV, int max_uV, unsigned *selector) int min_uV, int max_uV, unsigned *selector)
{ {
struct vexpress_regulator *reg = rdev_get_drvdata(regdev); return regmap_write(regdev->regmap, 0, min_uV);
return regmap_write(reg->regmap, 0, min_uV);
} }
static const struct regulator_ops vexpress_regulator_ops_ro = { static const struct regulator_ops vexpress_regulator_ops_ro = {
...@@ -57,44 +48,44 @@ static const struct regulator_ops vexpress_regulator_ops = { ...@@ -57,44 +48,44 @@ static const struct regulator_ops vexpress_regulator_ops = {
static int vexpress_regulator_probe(struct platform_device *pdev) static int vexpress_regulator_probe(struct platform_device *pdev)
{ {
struct vexpress_regulator *reg; struct regulator_desc *desc;
struct regulator_init_data *init_data; struct regulator_init_data *init_data;
struct regulator_config config = { }; struct regulator_config config = { };
struct regulator_dev *rdev;
struct regmap *regmap;
reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL); desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL);
if (!reg) if (!desc)
return -ENOMEM; return -ENOMEM;
reg->regmap = devm_regmap_init_vexpress_config(&pdev->dev); regmap = devm_regmap_init_vexpress_config(&pdev->dev);
if (IS_ERR(reg->regmap)) if (IS_ERR(regmap))
return PTR_ERR(reg->regmap); return PTR_ERR(regmap);
reg->desc.name = dev_name(&pdev->dev); desc->name = dev_name(&pdev->dev);
reg->desc.type = REGULATOR_VOLTAGE; desc->type = REGULATOR_VOLTAGE;
reg->desc.owner = THIS_MODULE; desc->owner = THIS_MODULE;
reg->desc.continuous_voltage_range = true; desc->continuous_voltage_range = true;
init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
&reg->desc); desc);
if (!init_data) if (!init_data)
return -EINVAL; return -EINVAL;
init_data->constraints.apply_uV = 0; init_data->constraints.apply_uV = 0;
if (init_data->constraints.min_uV && init_data->constraints.max_uV) if (init_data->constraints.min_uV && init_data->constraints.max_uV)
reg->desc.ops = &vexpress_regulator_ops; desc->ops = &vexpress_regulator_ops;
else else
reg->desc.ops = &vexpress_regulator_ops_ro; desc->ops = &vexpress_regulator_ops_ro;
config.regmap = regmap;
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.init_data = init_data; config.init_data = init_data;
config.driver_data = reg;
config.of_node = pdev->dev.of_node; config.of_node = pdev->dev.of_node;
reg->regdev = devm_regulator_register(&pdev->dev, &reg->desc, &config); rdev = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(reg->regdev)) if (IS_ERR(rdev))
return PTR_ERR(reg->regdev); return PTR_ERR(rdev);
platform_set_drvdata(pdev, reg);
return 0; return 0;
} }
......
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