Skip to contentSkip to conversation

regulator: Simplify max77693 driver

PATCH RESEND Superseded Krzysztof Kozlowski 1 participant 4 messages Feb 24, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover regulator: Simplify max77693 driver

Hi,

Simplify the max77693 regulator driver by moving DT parse code out to regulator core.

This removes also board file support. Exynos based boards are DT-only. This removal allows bigger simplification of driver so overall diffstat is nice: -93 deletions, 12 additions.

Dependency: The second patch depends on first one.

Best regards,
Krzysztof

Krzysztof Kozlowski (2):
regulator: max77693: Let core parse DT and drop board files support
mfd: max77693: Remove unused structures

 drivers/regulator/max77693.c | 93 +++++---------------------------------------
 include/linux/mfd/max77693.h | 12 +-----
 2 files changed, 10 insertions(+), 95 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH RESEND 1/2 regulator: max77693: Let core parse DT and drop board files support

Simplify the driver by removing board file support and letting regulator core to parse DT.

The max77693 regulator driver is used only on Exynos based boards which are DT-only. Board files for Exynos are not supported.

---
 drivers/regulator/max77693.c | 93 +++++---------------------------------------
 1 file changed, 9 insertions(+), 84 deletions(-)
drivers/regulator/max77693.c +9 -84
index 07b313e51b21..9665a488e2f1 100644
@@ -128,6 +128,8 @@ static struct regulator_ops max77693_charger_ops = {
 #define regulator_desc_esafeout(_num)	{			\
 	.name		= "ESAFEOUT"#_num,			\
 	.id		= MAX77693_ESAFEOUT##_num,		\
+	.of_match	= of_match_ptr("ESAFEOUT"#_num),	\
+	.regulators_node	= of_match_ptr("regulators"),	\
 	.n_voltages	= 4,					\
 	.ops		= &max77693_safeout_ops,		\
 	.type		= REGULATOR_VOLTAGE,			\
@@ -145,6 +147,8 @@ static const struct regulator_desc regulators[] = {
 	{
 		.name = "CHARGER",
 		.id = MAX77693_CHARGER,
+		.of_match = of_match_ptr("CHARGER"),
+		.regulators_node = of_match_ptr("regulators"),
 		.ops = &max77693_charger_ops,
 		.type = REGULATOR_CURRENT,
 		.owner = THIS_MODULE,
@@ -154,102 +158,23 @@ static const struct regulator_desc regulators[] = {
 	},
 };
 
-#ifdef CONFIG_OF
-static int max77693_pmic_dt_parse_rdata(struct device *dev,
-					struct max77693_regulator_data **rdata)
-{
-	struct device_node *np;
-	struct of_regulator_match *rmatch;
-	struct max77693_regulator_data *tmp;
-	int i, matched = 0;
-
-	np = of_get_child_by_name(dev->parent->of_node, "regulators");
-	if (!np)
-		return -EINVAL;
-
-	rmatch = devm_kzalloc(dev,
-		 sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL);
-	if (!rmatch) {
-		of_node_put(np);
-		return -ENOMEM;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(regulators); i++)
-		rmatch[i].name = regulators[i].name;
-
-	matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators));
-	of_node_put(np);
-	if (matched <= 0)
-		return matched;
-	*rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL);
-	if (!(*rdata))
-		return -ENOMEM;
-
-	tmp = *rdata;
-
-	for (i = 0; i < matched; i++) {
-		tmp->initdata = rmatch[i].init_data;
-		tmp->of_node = rmatch[i].of_node;
-		tmp->id = regulators[i].id;
-		tmp++;
-	}
-
-	return matched;
-}
-#else
-static int max77693_pmic_dt_parse_rdata(struct device *dev,
-					struct max77693_regulator_data **rdata)
-{
-	return 0;
-}
-#endif /* CONFIG_OF */
-
-static int max77693_pmic_init_rdata(struct device *dev,
-				    struct max77693_regulator_data **rdata)
-{
-	struct max77693_platform_data *pdata;
-	int num_regulators = 0;
-
-	pdata = dev_get_platdata(dev->parent);
-	if (pdata) {
-		*rdata = pdata->regulators;
-		num_regulators = pdata->num_regulators;
-	}
-
-	if (!(*rdata) && dev->parent->of_node)
-		num_regulators = max77693_pmic_dt_parse_rdata(dev, rdata);
-
-	return num_regulators;
-}
-
 static int max77693_pmic_probe(struct platform_device *pdev)
 {
 	struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
-	struct max77693_regulator_data *rdata = NULL;
-	int num_rdata, i;
+	int i;
 	struct regulator_config config = { };
 
-	num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata);
-	if (!rdata || num_rdata <= 0) {
-		dev_err(&pdev->dev, "No init data supplied.\n");
-		return -ENODEV;
-	}
-
-	config.dev = &pdev->dev;
+	config.dev = iodev->dev;
 	config.regmap = iodev->regmap;
 
-	for (i = 0; i < num_rdata; i++) {
-		int id = rdata[i].id;
+	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
 		struct regulator_dev *rdev;
 
-		config.init_data = rdata[i].initdata;
-		config.of_node = rdata[i].of_node;
-
 		rdev = devm_regulator_register(&pdev->dev,
-						&regulators[id], &config);
+						&regulators[i], &config);
 		if (IS_ERR(rdev)) {
 			dev_err(&pdev->dev,
-				"Failed to initialize regulator-%d\n", id);
+				"Failed to initialize regulator-%d\n", i);
 			return PTR_ERR(rdev);
 		}
 	}
Signature · 1 line
1.9.1
#2 lore raw

PATCH RESEND 2/2 mfd: max77693: Remove unused structures

In reply to Krzysztof Kozlowski

The max77693 regulator driver no longer supports board files. Remove the left-overs. Additionally fix name of device in comment.

---
 include/linux/mfd/max77693.h | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
include/linux/mfd/max77693.h +1 -11
index f0b6585cd874..09a4dedaeea8 100644
@@ -30,7 +30,7 @@
 #ifndef __LINUX_MFD_MAX77693_H
 #define __LINUX_MFD_MAX77693_H
 
-/* MAX77686 regulator IDs */
+/* MAX77693 regulator IDs */
 enum max77693_regulators {
 	MAX77693_ESAFEOUT1 = 0,
 	MAX77693_ESAFEOUT2,
@@ -38,12 +38,6 @@ enum max77693_regulators {
 	MAX77693_REG_MAX,
 };
 
-struct max77693_regulator_data {
-	int id;
-	struct regulator_init_data *initdata;
-	struct device_node *of_node;
-};
-
 struct max77693_reg_data {
 	u8 addr;
 	u8 data;
@@ -103,10 +97,6 @@ struct max77693_led_platform_data {
 /* MAX77693 */
 
 struct max77693_platform_data {
-	/* regulator data */
-	struct max77693_regulator_data *regulators;
-	int num_regulators;
-
 	/* muic data */
 	struct max77693_muic_platform_data *muic_data;
 	struct max77693_led_platform_data *led_data;
Signature · 1 line
1.9.1
#3 lore raw

Re: [RESEND PATCH 2/2] mfd: max77693: Remove unused structures

Quoted 2 lines · Krzysztof Kozlowski

The max77693 regulator driver no longer supports board files. Remove the left-overs. Additionally fix name of device in comment.

I just noticed that Lee Jones already acked this:
https://lkml.org/lkml/2015/1/20/552

So if the patchset looks OK, it can be picked through one tree (e.g. regulator).

Best regards,
Krzysztof

Quoted 5 lines
---
 include/linux/mfd/max77693.h | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)