diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-01-24 21:26:32 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-26 21:56:13 -0500 |
commit | b4895e2ca58a67ebab11f4671cc301fef0eedeb7 (patch) | |
tree | 6020f72921d4380f24ada2f1ed9a6fb47d357518 /drivers/regulator/max8997.c | |
parent | 949db153b6466c6f7cad5a427ecea94985927311 (diff) |
regulator: max8997: Fix using wrong dev argument at various places
Use &pdev->dev rather than iodev->dev for dev_err(), dev_warn() and dev_info().
Use &pdev->dev rather than iodev->dev for devm_kzalloc() and
of_get_regulator_init_data(), this fixes memory leak.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r-- | drivers/regulator/max8997.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 02be7fcae32f..836908ce505e 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -934,7 +934,7 @@ static struct regulator_desc regulators[] = { | |||
934 | }; | 934 | }; |
935 | 935 | ||
936 | #ifdef CONFIG_OF | 936 | #ifdef CONFIG_OF |
937 | static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, | 937 | static int max8997_pmic_dt_parse_dvs_gpio(struct platform_device *pdev, |
938 | struct max8997_platform_data *pdata, | 938 | struct max8997_platform_data *pdata, |
939 | struct device_node *pmic_np) | 939 | struct device_node *pmic_np) |
940 | { | 940 | { |
@@ -944,7 +944,7 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, | |||
944 | gpio = of_get_named_gpio(pmic_np, | 944 | gpio = of_get_named_gpio(pmic_np, |
945 | "max8997,pmic-buck125-dvs-gpios", i); | 945 | "max8997,pmic-buck125-dvs-gpios", i); |
946 | if (!gpio_is_valid(gpio)) { | 946 | if (!gpio_is_valid(gpio)) { |
947 | dev_err(iodev->dev, "invalid gpio[%d]: %d\n", i, gpio); | 947 | dev_err(&pdev->dev, "invalid gpio[%d]: %d\n", i, gpio); |
948 | return -EINVAL; | 948 | return -EINVAL; |
949 | } | 949 | } |
950 | pdata->buck125_gpios[i] = gpio; | 950 | pdata->buck125_gpios[i] = gpio; |
@@ -952,22 +952,23 @@ static int max8997_pmic_dt_parse_dvs_gpio(struct max8997_dev *iodev, | |||
952 | return 0; | 952 | return 0; |
953 | } | 953 | } |
954 | 954 | ||
955 | static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | 955 | static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, |
956 | struct max8997_platform_data *pdata) | 956 | struct max8997_platform_data *pdata) |
957 | { | 957 | { |
958 | struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); | ||
958 | struct device_node *pmic_np, *regulators_np, *reg_np; | 959 | struct device_node *pmic_np, *regulators_np, *reg_np; |
959 | struct max8997_regulator_data *rdata; | 960 | struct max8997_regulator_data *rdata; |
960 | unsigned int i, dvs_voltage_nr = 1, ret; | 961 | unsigned int i, dvs_voltage_nr = 1, ret; |
961 | 962 | ||
962 | pmic_np = iodev->dev->of_node; | 963 | pmic_np = iodev->dev->of_node; |
963 | if (!pmic_np) { | 964 | if (!pmic_np) { |
964 | dev_err(iodev->dev, "could not find pmic sub-node\n"); | 965 | dev_err(&pdev->dev, "could not find pmic sub-node\n"); |
965 | return -ENODEV; | 966 | return -ENODEV; |
966 | } | 967 | } |
967 | 968 | ||
968 | regulators_np = of_find_node_by_name(pmic_np, "regulators"); | 969 | regulators_np = of_find_node_by_name(pmic_np, "regulators"); |
969 | if (!regulators_np) { | 970 | if (!regulators_np) { |
970 | dev_err(iodev->dev, "could not find regulators sub-node\n"); | 971 | dev_err(&pdev->dev, "could not find regulators sub-node\n"); |
971 | return -EINVAL; | 972 | return -EINVAL; |
972 | } | 973 | } |
973 | 974 | ||
@@ -976,11 +977,10 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | |||
976 | for_each_child_of_node(regulators_np, reg_np) | 977 | for_each_child_of_node(regulators_np, reg_np) |
977 | pdata->num_regulators++; | 978 | pdata->num_regulators++; |
978 | 979 | ||
979 | rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * | 980 | rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * |
980 | pdata->num_regulators, GFP_KERNEL); | 981 | pdata->num_regulators, GFP_KERNEL); |
981 | if (!rdata) { | 982 | if (!rdata) { |
982 | dev_err(iodev->dev, "could not allocate memory for " | 983 | dev_err(&pdev->dev, "could not allocate memory for regulator data\n"); |
983 | "regulator data\n"); | ||
984 | return -ENOMEM; | 984 | return -ENOMEM; |
985 | } | 985 | } |
986 | 986 | ||
@@ -991,14 +991,14 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | |||
991 | break; | 991 | break; |
992 | 992 | ||
993 | if (i == ARRAY_SIZE(regulators)) { | 993 | if (i == ARRAY_SIZE(regulators)) { |
994 | dev_warn(iodev->dev, "don't know how to configure " | 994 | dev_warn(&pdev->dev, "don't know how to configure regulator %s\n", |
995 | "regulator %s\n", reg_np->name); | 995 | reg_np->name); |
996 | continue; | 996 | continue; |
997 | } | 997 | } |
998 | 998 | ||
999 | rdata->id = i; | 999 | rdata->id = i; |
1000 | rdata->initdata = of_get_regulator_init_data( | 1000 | rdata->initdata = of_get_regulator_init_data(&pdev->dev, |
1001 | iodev->dev, reg_np); | 1001 | reg_np); |
1002 | rdata->reg_node = reg_np; | 1002 | rdata->reg_node = reg_np; |
1003 | rdata++; | 1003 | rdata++; |
1004 | } | 1004 | } |
@@ -1014,7 +1014,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | |||
1014 | 1014 | ||
1015 | if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs || | 1015 | if (pdata->buck1_gpiodvs || pdata->buck2_gpiodvs || |
1016 | pdata->buck5_gpiodvs) { | 1016 | pdata->buck5_gpiodvs) { |
1017 | ret = max8997_pmic_dt_parse_dvs_gpio(iodev, pdata, pmic_np); | 1017 | ret = max8997_pmic_dt_parse_dvs_gpio(pdev, pdata, pmic_np); |
1018 | if (ret) | 1018 | if (ret) |
1019 | return -EINVAL; | 1019 | return -EINVAL; |
1020 | 1020 | ||
@@ -1025,8 +1025,7 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | |||
1025 | } else { | 1025 | } else { |
1026 | if (pdata->buck125_default_idx >= 8) { | 1026 | if (pdata->buck125_default_idx >= 8) { |
1027 | pdata->buck125_default_idx = 0; | 1027 | pdata->buck125_default_idx = 0; |
1028 | dev_info(iodev->dev, "invalid value for " | 1028 | dev_info(&pdev->dev, "invalid value for default dvs index, using 0 instead\n"); |
1029 | "default dvs index, using 0 instead\n"); | ||
1030 | } | 1029 | } |
1031 | } | 1030 | } |
1032 | 1031 | ||
@@ -1040,28 +1039,28 @@ static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | |||
1040 | if (of_property_read_u32_array(pmic_np, | 1039 | if (of_property_read_u32_array(pmic_np, |
1041 | "max8997,pmic-buck1-dvs-voltage", | 1040 | "max8997,pmic-buck1-dvs-voltage", |
1042 | pdata->buck1_voltage, dvs_voltage_nr)) { | 1041 | pdata->buck1_voltage, dvs_voltage_nr)) { |
1043 | dev_err(iodev->dev, "buck1 voltages not specified\n"); | 1042 | dev_err(&pdev->dev, "buck1 voltages not specified\n"); |
1044 | return -EINVAL; | 1043 | return -EINVAL; |
1045 | } | 1044 | } |
1046 | 1045 | ||
1047 | if (of_property_read_u32_array(pmic_np, | 1046 | if (of_property_read_u32_array(pmic_np, |
1048 | "max8997,pmic-buck2-dvs-voltage", | 1047 | "max8997,pmic-buck2-dvs-voltage", |
1049 | pdata->buck2_voltage, dvs_voltage_nr)) { | 1048 | pdata->buck2_voltage, dvs_voltage_nr)) { |
1050 | dev_err(iodev->dev, "buck2 voltages not specified\n"); | 1049 | dev_err(&pdev->dev, "buck2 voltages not specified\n"); |
1051 | return -EINVAL; | 1050 | return -EINVAL; |
1052 | } | 1051 | } |
1053 | 1052 | ||
1054 | if (of_property_read_u32_array(pmic_np, | 1053 | if (of_property_read_u32_array(pmic_np, |
1055 | "max8997,pmic-buck5-dvs-voltage", | 1054 | "max8997,pmic-buck5-dvs-voltage", |
1056 | pdata->buck5_voltage, dvs_voltage_nr)) { | 1055 | pdata->buck5_voltage, dvs_voltage_nr)) { |
1057 | dev_err(iodev->dev, "buck5 voltages not specified\n"); | 1056 | dev_err(&pdev->dev, "buck5 voltages not specified\n"); |
1058 | return -EINVAL; | 1057 | return -EINVAL; |
1059 | } | 1058 | } |
1060 | 1059 | ||
1061 | return 0; | 1060 | return 0; |
1062 | } | 1061 | } |
1063 | #else | 1062 | #else |
1064 | static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev, | 1063 | static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, |
1065 | struct max8997_platform_data *pdata) | 1064 | struct max8997_platform_data *pdata) |
1066 | { | 1065 | { |
1067 | return 0; | 1066 | return 0; |
@@ -1085,7 +1084,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | if (iodev->dev->of_node) { | 1086 | if (iodev->dev->of_node) { |
1088 | ret = max8997_pmic_dt_parse_pdata(iodev, pdata); | 1087 | ret = max8997_pmic_dt_parse_pdata(pdev, pdata); |
1089 | if (ret) | 1088 | if (ret) |
1090 | return ret; | 1089 | return ret; |
1091 | } | 1090 | } |