Skip to contentSkip to conversation

nvmem: qcom-spmi-sdam: fix module autoloading

PATCH In review Johan Hovold 3 participants 5 messages Jan 26, 2023 – Jan 27, 2023

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

cover nvmem: qcom-spmi-sdam: fix module autoloading

The Qualcomm SDAM nvme driver did not have a module device table, which prevents userspace from autoloading the driver when built as a module.

The driver was also being registered at subsys init time when built in despite the fact that it can also be built as a module, which makes little sense. There are currently no in-tree users of this driver and there's no reason why we can't just let driver core sort out the probe order.

Note that this driver will be used to implement support for the PMIC RTC on Qualcomm platforms where the time registers are read-only (sic).

Johan

Johan Hovold (2):
nvmem: qcom-spmi-sdam: fix module autoloading
nvmem: qcom-spmi-sdam: register at device init time

 drivers/nvmem/qcom-spmi-sdam.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/2 nvmem: qcom-spmi-sdam: fix module autoloading

Add the missing module device table so that the driver can be autoloaded when built as a module.

Fixes 40ce9798794f ("nvmem: add QTI SDAM driver")
---
 drivers/nvmem/qcom-spmi-sdam.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nvmem/qcom-spmi-sdam.c +1 -0
index 4fcb63507ecd..8499892044b7 100644
@@ -166,6 +166,7 @@ static const struct of_device_id sdam_match_table[] = {
 	{ .compatible = "qcom,spmi-sdam" },
 	{},
 };
+MODULE_DEVICE_TABLE(of, sdam_match_table);
 
 static struct platform_driver sdam_driver = {
 	.driver = {
Signature · 1 line
2.39.1
#2 lore raw

PATCH 2/2 nvmem: qcom-spmi-sdam: register at device init time

In reply to Johan Hovold

There are currently no in-tree users of the Qualcomm SDAM nvmem driver and there is generally no point in registering a driver that can be built as a module at subsys init time.

Register the driver at the normal device init time instead and let driver core sort out the probe order.

---
 drivers/nvmem/qcom-spmi-sdam.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/nvmem/qcom-spmi-sdam.c +1 -12
index 8499892044b7..f822790db49e 100644
@@ -175,18 +175,7 @@ static struct platform_driver sdam_driver = {
 	},
 	.probe		= sdam_probe,
 };
-
-static int __init sdam_init(void)
-{
-	return platform_driver_register(&sdam_driver);
-}
-subsys_initcall(sdam_init);
-
-static void __exit sdam_exit(void)
-{
-	return platform_driver_unregister(&sdam_driver);
-}
-module_exit(sdam_exit);
+module_platform_driver(sdam_driver);
 
 MODULE_DESCRIPTION("QCOM SPMI SDAM driver");
 MODULE_LICENSE("GPL v2");
Signature · 1 line
2.39.1
Reviewed-by on the v1 series
#3 lore raw
In reply to Johan Hovold
Quoted 9 lines · Johan Hovold

The Qualcomm SDAM nvme driver did not have a module device table, which prevents userspace from autoloading the driver when built as a module.

The driver was also being registered at subsys init time when built in despite the fact that it can also be built as a module, which makes little sense. There are currently no in-tree users of this driver and there's no reason why we can't just let driver core sort out the probe order.

Quoted 5 lines

Note that this driver will be used to implement support for the PMIC RTC on Qualcomm platforms where the time registers are read-only (sic).

Johan

Quoted 11 lines

Johan Hovold (2):
nvmem: qcom-spmi-sdam: fix module autoloading
nvmem: qcom-spmi-sdam: register at device init time

 drivers/nvmem/qcom-spmi-sdam.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.1
#4 lore raw
In reply to Johan Hovold
Quoted 9 lines · Johan Hovold

The Qualcomm SDAM nvme driver did not have a module device table, which prevents userspace from autoloading the driver when built as a module.

The driver was also being registered at subsys init time when built in despite the fact that it can also be built as a module, which makes little sense. There are currently no in-tree users of this driver and there's no reason why we can't just let driver core sort out the probe order.

Quoted 5 lines

Note that this driver will be used to implement support for the PMIC RTC on Qualcomm platforms where the time registers are read-only (sic).

Johan

Applied thanks,

--srin

Quoted 8 lines

Johan Hovold (2):
nvmem: qcom-spmi-sdam: fix module autoloading
nvmem: qcom-spmi-sdam: register at device init time

  drivers/nvmem/qcom-spmi-sdam.c | 14 ++------------
  1 file changed, 2 insertions(+), 12 deletions(-)