[PATCH 0/2] regulator: mt6397: Add platform and OF tables and fix module autoload

STALE3925d

3 messages, 1 author, 2016-01-25 · open the first message on its own page

[PATCH 0/2] regulator: mt6397: Add platform and OF tables and fix module autoload

From: Javier Martinez Canillas <hidden>
Date: 2016-01-25 14:37:39

Hello Mark,

This small series add missing platform device and OF tables to the mt6397
regulator driver. I noticed these when reviewing a new regulator driver
that was posted since the submitted driver had the same issues [0].

The patches were just built tested so testing on an actual HW will be highly
appreciated.

[0]: https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1058808.html

Best regards,
Javier


Javier Martinez Canillas (2):
  regulator: mt6397: Add platform device ID table
  regulator: mt6397: Add OF match table

 drivers/regulator/mt6397-regulator.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

-- 
2.5.0

[PATCH 1/2] regulator: mt6397: Add platform device ID table

From: Javier Martinez Canillas <hidden>
Date: 2016-01-25 14:37:54

The platform bus_type .match callback attempts to match the platform device
name with an entry on the .id_table if provided and fallbacks to match with
the driver's name if a table is not provided.

Using a platform device ID to match is more explicit, allows the driver to
support more than one device and also the MODULE_DEVICE_TABLE macro can be
used to export the module aliases information instead of the MODULE_ALIAS.

Signed-off-by: Javier Martinez Canillas <redacted>
---

 drivers/regulator/mt6397-regulator.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/mt6397-regulator.c b/drivers/regulator/mt6397-regulator.c
index a5b2f4762677..585f0399a36b 100644
--- a/drivers/regulator/mt6397-regulator.c
+++ b/drivers/regulator/mt6397-regulator.c
@@ -317,11 +317,18 @@ static int mt6397_regulator_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct platform_device_id mt6397_platform_ids[] = {
+	{"mt6397-regulator", 0},
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(platform, mt6397_platform_ids);
+
 static struct platform_driver mt6397_regulator_driver = {
 	.driver = {
 		.name = "mt6397-regulator",
 	},
 	.probe = mt6397_regulator_probe,
+	.id_table = mt6397_platform_ids,
 };
 
 module_platform_driver(mt6397_regulator_driver);
@@ -329,4 +336,3 @@ module_platform_driver(mt6397_regulator_driver);
 MODULE_AUTHOR("Flora Fu <flora.fu@mediatek.com>");
 MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6397 PMIC");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:mt6397-regulator");
-- 
2.5.0

[PATCH 2/2] regulator: mt6397: Add OF match table

From: Javier Martinez Canillas <hidden>
Date: 2016-01-25 14:38:27

The Documentation/devicetree/bindings/regulator/mt6397-regulator.txt doc
mentions that a compatible "mediatek,mt6397-regulator" is required for
the MT6397 device node but the driver doesn't provide a OF match table so
the platform bus .match fallbacks to match using the driver name instead.

This also means that module auto-loading is broken for this driver since
the MFD driver that register the device, has a .of_compatible set so the
platform .uevent callback reports a OF modalias that's not in the module.

Signed-off-by: Javier Martinez Canillas <redacted>

---

 drivers/regulator/mt6397-regulator.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/drivers/regulator/mt6397-regulator.c b/drivers/regulator/mt6397-regulator.c
index 585f0399a36b..17a5b6c2d6a9 100644
--- a/drivers/regulator/mt6397-regulator.c
+++ b/drivers/regulator/mt6397-regulator.c
@@ -323,9 +323,16 @@ static const struct platform_device_id mt6397_platform_ids[] = {
 };
 MODULE_DEVICE_TABLE(platform, mt6397_platform_ids);
 
+static const struct of_device_id mt6397_of_match[] = {
+	{ .compatible = "mediatek,mt6397-regulator", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, mt6397_of_match);
+
 static struct platform_driver mt6397_regulator_driver = {
 	.driver = {
 		.name = "mt6397-regulator",
+		.of_match_table = of_match_ptr(mt6397_of_match),
 	},
 	.probe = mt6397_regulator_probe,
 	.id_table = mt6397_platform_ids,
-- 
2.5.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help