regulator: fan53555: change fan53555_parse_dt() to read only DT parameters
Currently, fan53555_parse_dt() does a platform data allocation in addition to reading device tree parameters. Move the memory allocation out of fan53555_parse_dt() and change it only to parse device tree parameters to match its name. This helps to expand the function to read other device tree parameters. CRs-Fixed: 968575 Change-Id: Id876d54bede15c73a298a6bfa68af7097115e36b Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
This commit is contained in:
parent
3c3c947e71
commit
1138183d9b
1 changed files with 20 additions and 18 deletions
|
@ -302,26 +302,27 @@ static const struct regmap_config fan53555_regmap_config = {
|
|||
.val_bits = 8,
|
||||
};
|
||||
|
||||
static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
|
||||
struct device_node *np,
|
||||
const struct regulator_desc *desc)
|
||||
static int fan53555_parse_dt(struct fan53555_device_info *di,
|
||||
struct fan53555_platform_data *pdata,
|
||||
const struct regulator_desc *desc)
|
||||
{
|
||||
struct fan53555_platform_data *pdata;
|
||||
struct device *dev = di->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
int ret;
|
||||
u32 tmp;
|
||||
|
||||
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return NULL;
|
||||
|
||||
pdata->regulator = of_get_regulator_init_data(dev, np, desc);
|
||||
if (!pdata->regulator) {
|
||||
dev_err(dev, "regulator init data is missing\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32(np, "fcs,suspend-voltage-selector",
|
||||
&tmp);
|
||||
if (!ret)
|
||||
pdata->sleep_vsel_id = tmp;
|
||||
|
||||
return pdata;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct of_device_id fan53555_dt_ids[] = {
|
||||
|
@ -342,7 +343,6 @@ MODULE_DEVICE_TABLE(of, fan53555_dt_ids);
|
|||
static int fan53555_regulator_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct device_node *np = client->dev.of_node;
|
||||
struct fan53555_device_info *di;
|
||||
struct fan53555_platform_data *pdata;
|
||||
struct regulator_config config = { };
|
||||
|
@ -355,14 +355,17 @@ static int fan53555_regulator_probe(struct i2c_client *client,
|
|||
return -ENOMEM;
|
||||
|
||||
pdata = dev_get_platdata(&client->dev);
|
||||
if (!pdata)
|
||||
pdata = fan53555_parse_dt(&client->dev, np, &di->desc);
|
||||
|
||||
if (!pdata || !pdata->regulator) {
|
||||
dev_err(&client->dev, "Platform data not found!\n");
|
||||
return -ENODEV;
|
||||
if (!pdata) {
|
||||
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
|
||||
if (!pdata)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
di->dev = &client->dev;
|
||||
ret = fan53555_parse_dt(di, pdata, &di->desc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
di->regulator = pdata->regulator;
|
||||
if (client->dev.of_node) {
|
||||
const struct of_device_id *match;
|
||||
|
@ -391,7 +394,6 @@ static int fan53555_regulator_probe(struct i2c_client *client,
|
|||
dev_err(&client->dev, "Failed to allocate regmap!\n");
|
||||
return PTR_ERR(di->regmap);
|
||||
}
|
||||
di->dev = &client->dev;
|
||||
i2c_set_clientdata(client, di);
|
||||
/* Get chip ID */
|
||||
ret = regmap_read(di->regmap, FAN53555_ID1, &val);
|
||||
|
@ -420,7 +422,7 @@ static int fan53555_regulator_probe(struct i2c_client *client,
|
|||
config.init_data = di->regulator;
|
||||
config.regmap = di->regmap;
|
||||
config.driver_data = di;
|
||||
config.of_node = np;
|
||||
config.of_node = client->dev.of_node;
|
||||
|
||||
ret = fan53555_regulator_register(di, &config);
|
||||
if (ret < 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue