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

regulator: pbias: Get rid of struct pbias_regulator_data

Only the desc field is really used, so use struct regulator_desc instead.
Then struct pbias_regulator_data can be removed.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20191007114320.20977-1-axel.lin@ingics.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 151b0379
...@@ -38,15 +38,6 @@ struct pbias_reg_info { ...@@ -38,15 +38,6 @@ struct pbias_reg_info {
int n_voltages; int n_voltages;
}; };
struct pbias_regulator_data {
struct regulator_desc desc;
void __iomem *pbias_addr;
struct regulator_dev *dev;
struct regmap *syscon;
const struct pbias_reg_info *info;
int voltage;
};
struct pbias_of_data { struct pbias_of_data {
unsigned int offset; unsigned int offset;
}; };
...@@ -157,13 +148,13 @@ MODULE_DEVICE_TABLE(of, pbias_of_match); ...@@ -157,13 +148,13 @@ MODULE_DEVICE_TABLE(of, pbias_of_match);
static int pbias_regulator_probe(struct platform_device *pdev) static int pbias_regulator_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct pbias_regulator_data *drvdata;
struct resource *res; struct resource *res;
struct regulator_config cfg = { }; struct regulator_config cfg = { };
struct regulator_desc *desc;
struct regulator_dev *rdev;
struct regmap *syscon; struct regmap *syscon;
const struct pbias_reg_info *info; const struct pbias_reg_info *info;
int ret = 0; int ret, count, idx;
int count, idx, data_idx = 0;
const struct pbias_of_data *data; const struct pbias_of_data *data;
unsigned int offset; unsigned int offset;
...@@ -172,10 +163,8 @@ static int pbias_regulator_probe(struct platform_device *pdev) ...@@ -172,10 +163,8 @@ static int pbias_regulator_probe(struct platform_device *pdev)
if (count < 0) if (count < 0)
return count; return count;
drvdata = devm_kcalloc(&pdev->dev, desc = devm_kcalloc(&pdev->dev, count, sizeof(*desc), GFP_KERNEL);
count, sizeof(struct pbias_regulator_data), if (!desc)
GFP_KERNEL);
if (!drvdata)
return -ENOMEM; return -ENOMEM;
syscon = syscon_regmap_lookup_by_phandle(np, "syscon"); syscon = syscon_regmap_lookup_by_phandle(np, "syscon");
...@@ -198,7 +187,7 @@ static int pbias_regulator_probe(struct platform_device *pdev) ...@@ -198,7 +187,7 @@ static int pbias_regulator_probe(struct platform_device *pdev)
cfg.regmap = syscon; cfg.regmap = syscon;
cfg.dev = &pdev->dev; cfg.dev = &pdev->dev;
for (idx = 0; idx < PBIAS_NUM_REGS && data_idx < count; idx++) { for (idx = 0; idx < PBIAS_NUM_REGS && count; idx++) {
if (!pbias_matches[idx].init_data || if (!pbias_matches[idx].init_data ||
!pbias_matches[idx].of_node) !pbias_matches[idx].of_node)
continue; continue;
...@@ -207,41 +196,35 @@ static int pbias_regulator_probe(struct platform_device *pdev) ...@@ -207,41 +196,35 @@ static int pbias_regulator_probe(struct platform_device *pdev)
if (!info) if (!info)
return -ENODEV; return -ENODEV;
drvdata[data_idx].syscon = syscon; desc->name = info->name;
drvdata[data_idx].info = info; desc->owner = THIS_MODULE;
drvdata[data_idx].desc.name = info->name; desc->type = REGULATOR_VOLTAGE;
drvdata[data_idx].desc.owner = THIS_MODULE; desc->ops = &pbias_regulator_voltage_ops;
drvdata[data_idx].desc.type = REGULATOR_VOLTAGE; desc->volt_table = info->pbias_volt_table;
drvdata[data_idx].desc.ops = &pbias_regulator_voltage_ops; desc->n_voltages = info->n_voltages;
drvdata[data_idx].desc.volt_table = info->pbias_volt_table; desc->enable_time = info->enable_time;
drvdata[data_idx].desc.n_voltages = info->n_voltages; desc->vsel_reg = offset;
drvdata[data_idx].desc.enable_time = info->enable_time; desc->vsel_mask = info->vmode;
drvdata[data_idx].desc.vsel_reg = offset; desc->enable_reg = offset;
drvdata[data_idx].desc.vsel_mask = info->vmode; desc->enable_mask = info->enable_mask;
drvdata[data_idx].desc.enable_reg = offset; desc->enable_val = info->enable;
drvdata[data_idx].desc.enable_mask = info->enable_mask; desc->disable_val = info->disable_val;
drvdata[data_idx].desc.enable_val = info->enable;
drvdata[data_idx].desc.disable_val = info->disable_val;
cfg.init_data = pbias_matches[idx].init_data; cfg.init_data = pbias_matches[idx].init_data;
cfg.driver_data = &drvdata[data_idx];
cfg.of_node = pbias_matches[idx].of_node; cfg.of_node = pbias_matches[idx].of_node;
drvdata[data_idx].dev = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev, desc, &cfg);
&drvdata[data_idx].desc, &cfg); if (IS_ERR(rdev)) {
if (IS_ERR(drvdata[data_idx].dev)) { ret = PTR_ERR(rdev);
ret = PTR_ERR(drvdata[data_idx].dev);
dev_err(&pdev->dev, dev_err(&pdev->dev,
"Failed to register regulator: %d\n", ret); "Failed to register regulator: %d\n", ret);
goto err_regulator; return ret;
} }
data_idx++; desc++;
count--;
} }
platform_set_drvdata(pdev, drvdata); return 0;
err_regulator:
return ret;
} }
static struct platform_driver pbias_regulator_driver = { static struct platform_driver pbias_regulator_driver = {
......
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