Merge remote-tracking branch 'regulator/fix/max8997' into tmp

This commit is contained in:
Mark Brown 2013-02-06 11:28:49 +00:00
Родитель c48c43aa2d b4895e2ca5
Коммит 3886f91b96
1 изменённых файлов: 19 добавлений и 20 удалений

Просмотреть файл

@ -934,7 +934,7 @@ static struct regulator_desc regulators[] = {
}; };
#ifdef CONFIG_OF #ifdef CONFIG_OF
static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, static int max8997_pmic_dt_parse_dvs_gpio(struct platform_device *pdev,
struct max8997_platform_data *pdata, struct max8997_platform_data *pdata,
struct device_node *pmic_np) struct device_node *pmic_np)
{ {
@ -944,7 +944,7 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev,
gpio = of_get_named_gpio(pmic_np, gpio = of_get_named_gpio(pmic_np,
"max8997,pmic-buck125-dvs-gpios", i); "max8997,pmic-buck125-dvs-gpios", i);
if (!gpio_is_valid(gpio)) { if (!gpio_is_valid(gpio)) {
dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio); dev_err(&pdev->dev, "invalid gpio[%d]: %d\n", i, gpio);
return -EINVAL; return -EINVAL;
} }
pdata->buck125_gpios[i] = gpio; pdata->buck125_gpios[i] = gpio;
@ -952,22 +952,23 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev,
return 0; return 0;
} }
static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
struct max8997_platform_data *pdata) struct max8997_platform_data *pdata)
{ {
struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
struct device_node *pmic_np, *regulators_np, *reg_np; struct device_node *pmic_np, *regulators_np, *reg_np;
struct max8997_regulator_data *rdata; struct max8997_regulator_data *rdata;
unsigned int i, dvs_voltage_nr = 1, ret; unsigned int i, dvs_voltage_nr = 1, ret;
pmic_np = iodev->dev->of_node; pmic_np = iodev->dev->of_node;
if (!pmic_np) { if (!pmic_np) {
dev_err(iodev->dev, "could not find pmic sub-node\n"); dev_err(&pdev->dev, "could not find pmic sub-node\n");
return -ENODEV; return -ENODEV;
} }
regulators_np = of_find_node_by_name(pmic_np, "regulators"); regulators_np = of_find_node_by_name(pmic_np, "regulators");
if (!regulators_np) { if (!regulators_np) {
dev_err(iodev->dev, "could not find regulators sub-node\n"); dev_err(&pdev->dev, "could not find regulators sub-node\n");
return -EINVAL; return -EINVAL;
} }
@ -976,11 +977,10 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
for_each_child_of_node(regulators_np, reg_np) for_each_child_of_node(regulators_np, reg_np)
pdata->num_regulators++; pdata->num_regulators++;
rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
pdata->num_regulators, GFP_KERNEL); pdata->num_regulators, GFP_KERNEL);
if (!rdata) { if (!rdata) {
dev_err(iodev->dev, "could not allocate memory for " dev_err(&pdev->dev, "could not allocate memory for regulator data\n");
"regulator data\n");
return -ENOMEM; return -ENOMEM;
} }
@ -991,14 +991,14 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
break; break;
if (i == ARRAY_SIZE(regulators)) { if (i == ARRAY_SIZE(regulators)) {
dev_warn(iodev->dev, "don't know how to configure " dev_warn(&pdev->dev, "don't know how to configure regulator %s\n",
"regulator %s\n", reg_np->name); reg_np->name);
continue; continue;
} }
rdata->id = i; rdata->id = i;
rdata->initdata = of_get_regulator_init_data( rdata->initdata = of_get_regulator_init_data(&pdev->dev,
iodev->dev, reg_np); reg_np);
rdata->reg_node = reg_np; rdata->reg_node = reg_np;
rdata++; rdata++;
} }
@ -1014,7 +1014,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs || if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs ||
pdata->buck5_gpiodvs) { pdata->buck5_gpiodvs) {
ret = max8997_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); ret = max8997_pmic_dt_parse_dvs_gpio(pdev, pdata, pmic_np);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
@ -1025,8 +1025,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
} else { } else {
if (pdata->buck125_default_idx >= 8) { if (pdata->buck125_default_idx >= 8) {
pdata->buck125_default_idx = 0; pdata->buck125_default_idx = 0;
dev_info(iodev->dev, "invalid value for " dev_info(&pdev->dev, "invalid value for default dvs index, using 0 instead\n");
"default dvs index, using 0 instead\n");
} }
} }
@ -1040,28 +1039,28 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
if (of_property_read_u32_array(pmic_np, if (of_property_read_u32_array(pmic_np,
"max8997,pmic-buck1-dvs-voltage", "max8997,pmic-buck1-dvs-voltage",
pdata->buck1_voltage, dvs_voltage_nr)) { pdata->buck1_voltage, dvs_voltage_nr)) {
dev_err(iodev->dev, "buck1 voltages not specified\n"); dev_err(&pdev->dev, "buck1 voltages not specified\n");
return -EINVAL; return -EINVAL;
} }
if (of_property_read_u32_array(pmic_np, if (of_property_read_u32_array(pmic_np,
"max8997,pmic-buck2-dvs-voltage", "max8997,pmic-buck2-dvs-voltage",
pdata->buck2_voltage, dvs_voltage_nr)) { pdata->buck2_voltage, dvs_voltage_nr)) {
dev_err(iodev->dev, "buck2 voltages not specified\n"); dev_err(&pdev->dev, "buck2 voltages not specified\n");
return -EINVAL; return -EINVAL;
} }
if (of_property_read_u32_array(pmic_np, if (of_property_read_u32_array(pmic_np,
"max8997,pmic-buck5-dvs-voltage", "max8997,pmic-buck5-dvs-voltage",
pdata->buck5_voltage, dvs_voltage_nr)) { pdata->buck5_voltage, dvs_voltage_nr)) {
dev_err(iodev->dev, "buck5 voltages not specified\n"); dev_err(&pdev->dev, "buck5 voltages not specified\n");
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
} }
#else #else
static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
struct max8997_platform_data *pdata) struct max8997_platform_data *pdata)
{ {
return 0; return 0;
@ -1085,7 +1084,7 @@ static int max8997_pmic_probe(struct platform_device *pdev)
} }
if (iodev->dev->of_node) { if (iodev->dev->of_node) {
ret = max8997_pmic_dt_parse_pdata(iodev, pdata); ret = max8997_pmic_dt_parse_pdata(pdev, pdata);
if (ret) if (ret)
return ret; return ret;
} }