Skip to contentSkip to conversation

regulator: tps65218: Add terminate entry for of_device_id table

PATCH Superseded Axel Lin 2 participants 3 messages Feb 18, 2014 – Feb 19, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 regulator: tps65218: Add terminate entry for of_device_id table

Fixes below build error:
FATAL: drivers/regulator/tps65218-regulator: struct of_device_id is not terminated with a NULL entry!

Also remove of_match_ptr as this is a DT-only driver.

---
 drivers/regulator/tps65218-regulator.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/regulator/tps65218-regulator.c +7 -8
index 958276c..00c0114 100644
@@ -96,6 +96,7 @@ static const struct of_device_id tps65218_of_match[] = {
 	TPS65218_OF_MATCH("ti,tps65218-dcdc5", tps65218_pmic_regs[DCDC5]),
 	TPS65218_OF_MATCH("ti,tps65218-dcdc6", tps65218_pmic_regs[DCDC6]),
 	TPS65218_OF_MATCH("ti,tps65218-ldo1", tps65218_pmic_regs[LDO1]),
+	{ }
 };
 MODULE_DEVICE_TABLE(of, tps65218_of_match);
 
@@ -242,14 +243,12 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
 	int id;
 
 	match = of_match_device(tps65218_of_match, &pdev->dev);
-	if (match) {
-		template = match->data;
-		id = template->id;
-		init_data = of_get_regulator_init_data(&pdev->dev,
-						      pdev->dev.of_node);
-	} else {
+	if (!match)
 		return -ENODEV;
-	}
+
+	template = match->data;
+	id = template->id;
+	init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node);
 
 	platform_set_drvdata(pdev, tps);
 
@@ -290,7 +289,7 @@ static struct platform_driver tps65218_regulator_driver = {
 	.driver = {
 		.name = "tps65218-pmic",
 		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(tps65218_of_match),
+		.of_match_table = tps65218_of_match,
 	},
 	.probe = tps65218_regulator_probe,
 	.remove = tps65218_regulator_remove,
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH 2/2 regulator: tps65218: Remove unnecessary regulator_unregister call

Current code uses devm_regulator_register() so the we don't need to explicitly call regulator_unregister() in .remove.
And then we don't need to save rdev pointer to tps->rdev[id].

---
 drivers/regulator/tps65218-regulator.c | 18 ------------------
 1 file changed, 18 deletions(-)
drivers/regulator/tps65218-regulator.c +0 -18
index 00c0114..cec72fa 100644
@@ -265,23 +265,6 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
 		return PTR_ERR(rdev);
 	}
 
-	/* Save regulator */
-	tps->rdev[id] = rdev;
-
-	return 0;
-}
-
-static int tps65218_regulator_remove(struct platform_device *pdev)
-{
-	struct tps65218 *tps = platform_get_drvdata(pdev);
-	const struct of_device_id	*match;
-	const struct tps_info		*template;
-
-	match = of_match_device(tps65218_of_match, &pdev->dev);
-	template = match->data;
-	regulator_unregister(tps->rdev[template->id]);
-	platform_set_drvdata(pdev, NULL);
-
 	return 0;
 }
 
@@ -292,7 +275,6 @@ static struct platform_driver tps65218_regulator_driver = {
 		.of_match_table = tps65218_of_match,
 	},
 	.probe = tps65218_regulator_probe,
-	.remove = tps65218_regulator_remove,
 };
 
 module_platform_driver(tps65218_regulator_driver);
Signature · 1 line
1.8.1.2
maintainer
#2 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

Fixes below build error:
FATAL: drivers/regulator/tps65218-regulator: struct of_device_id is not terminated with a NULL entry!

This is good (though I'm not seeing a build time error myself...).

Quoted 1 line

Also remove of_match_ptr as this is a DT-only driver.

This should really have been split out as a separate change. We probably also need an OF dependency in the Kconfig for this (there may be one on the MFD but having one here if the driver specficaly depends on DT is better to avoid bisection issues if the MFD gets updated).