Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57a04f61 authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "regulator: fan53555: change fan53555_parse_dt() to read only DT parameters" into msm-4.8

parents 9fe89b78 349cf069
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -344,26 +344,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,
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[] = {
@@ -384,7 +385,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 = { };
@@ -397,14 +397,17 @@ static int fan53555_regulator_probe(struct i2c_client *client,
		return -ENOMEM;

	pdata = dev_get_platdata(&client->dev);
	if (!pdata) {
		pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
		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;
			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;
@@ -433,7 +436,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);
@@ -462,7 +464,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)