mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 00/12] Add and use DEVM soc_device_register helper
@ 2026-11-11 17:56 Andrew Davis
  2026-11-11 17:57 ` [PATCH 01/12] base: soc: Implement devm_soc_device_register() helper function Andrew Davis
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Hello all,

Add device managed devm_soc_device_register() to automatically unregister
soc_devices thus leading to simplified SOC driver code.

Use this new helper for drivers which currently unregister manually and
have a device to tie to this new automatic unregistration.

Thanks,
Andrew

Andrew Davis (12):
  base: soc: Implement devm_soc_device_register() helper function
  soc: ep93xx: Use devm_soc_device_register() helper
  soc: imx8m: Use devm_soc_device_register() helper
  soc: imx9: Use devm_soc_device_register() helper
  soc: loongson: Use devm_soc_device_register() helper
  soc: mediatek: mtk-socinfo: Use devm_soc_device_register() helper
  soc: qcom: socinfo: Use devm_soc_device_register() helper
  soc: renesas: rz-sysc: Use devm_soc_device_register() helper
  soc: samsung: exynos-chipid: Use devm_soc_device_register() helper
  soc: ti: k3-socinfo: Use devm_soc_device_register() helper
  soc: versatile: realview: Use devm_soc_device_register() helper
  soc: vt8500: Use devm_soc_device_register() helper

 drivers/base/soc.c                    | 23 +++++++++++++++++++++++
 drivers/soc/cirrus/soc-ep93xx.c       |  2 +-
 drivers/soc/imx/soc-imx8m.c           | 11 +----------
 drivers/soc/imx/soc-imx9.c            |  2 +-
 drivers/soc/loongson/loongson2_guts.c | 10 ++--------
 drivers/soc/mediatek/mtk-socinfo.c    | 17 ++++-------------
 drivers/soc/qcom/socinfo.c            |  4 +---
 drivers/soc/renesas/rz-sysc.c         |  2 +-
 drivers/soc/samsung/exynos-chipid.c   | 12 +-----------
 drivers/soc/ti/k3-socinfo.c           |  2 +-
 drivers/soc/versatile/soc-realview.c  | 14 +-------------
 drivers/soc/vt8500/wmt-socinfo.c      | 11 +----------
 include/linux/sys_soc.h               | 16 ++++++++++++++++
 13 files changed, 54 insertions(+), 72 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 01/12] base: soc: Implement devm_soc_device_register() helper function
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 02/12] soc: ep93xx: Use devm_soc_device_register() helper Andrew Davis
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Add device managed devm_soc_device_register() to automatically unregister
soc_devices thus leading to simplified SOC driver code.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/base/soc.c      | 23 +++++++++++++++++++++++
 include/linux/sys_soc.h | 16 ++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index af7d71393774b..81a96e56fbc29 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -189,6 +189,29 @@ void soc_device_unregister(struct soc_device *soc_dev)
 }
 EXPORT_SYMBOL_GPL(soc_device_unregister);
 
+static void devm_soc_device_unregister(void *soc_dev)
+{
+	soc_device_unregister(soc_dev);
+}
+
+struct soc_device *devm_soc_device_register(struct device *dev,
+					    struct soc_device_attribute *soc_dev_attr)
+{
+	struct soc_device *soc_dev;
+	int ret;
+
+	soc_dev = soc_device_register(soc_dev_attr);
+	if (IS_ERR_OR_NULL(soc_dev))
+		return soc_dev;
+
+	ret = devm_add_action_or_reset(dev, devm_soc_device_unregister, soc_dev);
+	if (ret)
+		return ERR_PTR(ret);
+
+	return soc_dev;
+}
+EXPORT_SYMBOL_GPL(devm_soc_device_register);
+
 static int __init soc_bus_register(void)
 {
 	struct soc_device *soc_dev;
diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
index cedabf177f470..02b22add818b3 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -36,6 +36,22 @@ struct soc_device *soc_device_register(
  */
 void soc_device_unregister(struct soc_device *soc_dev);
 
+/**
+ * devm_soc_device_register - Resource-managed soc_device_register()
+ * @dev:		Device to register soc_dev for.
+ * @soc_plat_dev_attr: Attributes passed from platform to be attributed to a SoC
+ *
+ * Managed soc_device_register. soc_dev registered with this function is
+ * automatically unregistered on driver detach.
+ *
+ * Returns:
+ * - %NULL if the SoC bus is not yet registered;
+ * - on success, the newly allocated &struct soc_device pointer;
+ * - on failure, a negative error code as an ERR_PTR().
+ */
+struct soc_device *devm_soc_device_register(struct device *dev,
+					    struct soc_device_attribute *soc_dev_attr);
+
 /**
  * soc_device_to_device - helper function to fetch struct device
  * @soc: Previously registered SoC device container
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 02/12] soc: ep93xx: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
  2026-11-11 17:57 ` [PATCH 01/12] base: soc: Implement devm_soc_device_register() helper function Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 03/12] soc: imx8m: " Andrew Davis
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/cirrus/soc-ep93xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/cirrus/soc-ep93xx.c b/drivers/soc/cirrus/soc-ep93xx.c
index 5f6820925040c..2352bb76b6383 100644
--- a/drivers/soc/cirrus/soc-ep93xx.c
+++ b/drivers/soc/cirrus/soc-ep93xx.c
@@ -199,7 +199,7 @@ static int __init ep93xx_syscon_probe(struct platform_device *pdev)
 	attrs->family = "Cirrus Logic EP93xx";
 	attrs->revision = ep93xx_get_soc_rev(rev);
 
-	soc_dev = soc_device_register(attrs);
+	soc_dev = devm_soc_device_register(dev, attrs);
 	if (IS_ERR(soc_dev))
 		return PTR_ERR(soc_dev);
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 03/12] soc: imx8m: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
  2026-11-11 17:57 ` [PATCH 01/12] base: soc: Implement devm_soc_device_register() helper function Andrew Davis
  2026-11-11 17:57 ` [PATCH 02/12] soc: ep93xx: Use devm_soc_device_register() helper Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 04/12] soc: imx9: " Andrew Davis
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/imx/soc-imx8m.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index f0929916f0423..fc32336923aab 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -209,11 +209,6 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = {
 	devm_kasprintf((dev), GFP_KERNEL, "%d.%d", ((soc_rev) >> 4) & 0xf, (soc_rev) & 0xf) : \
 	"unknown"
 
-static void imx8m_unregister_soc(void *data)
-{
-	soc_device_unregister(data);
-}
-
 static void imx8m_unregister_cpufreq(void *data)
 {
 	platform_device_unregister(data);
@@ -284,14 +279,10 @@ static int imx8m_soc_probe(struct platform_device *pdev)
 	if (!soc_dev_attr->serial_number)
 		return -ENOMEM;
 
-	soc_dev = soc_device_register(soc_dev_attr);
+	soc_dev = devm_soc_device_register(dev, soc_dev_attr);
 	if (IS_ERR(soc_dev))
 		return PTR_ERR(soc_dev);
 
-	ret = devm_add_action(dev, imx8m_unregister_soc, soc_dev);
-	if (ret)
-		return ret;
-
 	pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id,
 		soc_dev_attr->revision);
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 04/12] soc: imx9: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (2 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 03/12] soc: imx8m: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 05/12] soc: loongson: " Andrew Davis
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/imx/soc-imx9.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/imx/soc-imx9.c b/drivers/soc/imx/soc-imx9.c
index cc8f3b7d39e6f..a4101dc590d55 100644
--- a/drivers/soc/imx/soc-imx9.c
+++ b/drivers/soc/imx/soc-imx9.c
@@ -67,7 +67,7 @@ static int imx9_soc_probe(struct platform_device *pdev)
 	if (!attr->serial_number)
 		return -ENOMEM;
 
-	sdev = soc_device_register(attr);
+	sdev = devm_soc_device_register(dev, attr);
 	if (IS_ERR(sdev))
 		return dev_err_probe(dev, PTR_ERR(sdev),
 				     "%s failed to register SoC as a device\n", __func__);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 05/12] soc: loongson: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (3 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 04/12] soc: imx9: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 06/12] soc: mediatek: mtk-socinfo: " Andrew Davis
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/loongson/loongson2_guts.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
index b28d101eb110b..7543fee3caf19 100644
--- a/drivers/soc/loongson/loongson2_guts.c
+++ b/drivers/soc/loongson/loongson2_guts.c
@@ -13,7 +13,6 @@
 #include <linux/platform_device.h>
 
 static struct soc_device_attribute soc_dev_attr;
-static struct soc_device *soc_dev;
 
 /*
  * Global Utility Registers.
@@ -95,6 +94,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node;
 	const struct loongson2_soc_die_attr *soc_die;
+	struct soc_device *soc_dev;
 	const char *machine;
 	u32 svr;
 
@@ -136,7 +136,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
 	if (!soc_dev_attr.revision)
 		return -ENOMEM;
 
-	soc_dev = soc_device_register(&soc_dev_attr);
+	soc_dev = devm_soc_device_register(dev, &soc_dev_attr);
 	if (IS_ERR(soc_dev))
 		return PTR_ERR(soc_dev);
 
@@ -148,11 +148,6 @@ static int loongson2_guts_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static void loongson2_guts_remove(struct platform_device *dev)
-{
-	soc_device_unregister(soc_dev);
-}
-
 /*
  * Table for matching compatible strings, for device tree
  * guts node, for Loongson-2 SoCs.
@@ -169,7 +164,6 @@ static struct platform_driver loongson2_guts_driver = {
 		.of_match_table = loongson2_guts_of_match,
 	},
 	.probe = loongson2_guts_probe,
-	.remove = loongson2_guts_remove,
 };
 
 static int __init loongson2_guts_init(void)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 06/12] soc: mediatek: mtk-socinfo: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (4 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 05/12] soc: loongson: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 07/12] soc: qcom: socinfo: " Andrew Davis
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/mediatek/mtk-socinfo.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-socinfo.c b/drivers/soc/mediatek/mtk-socinfo.c
index cd14706c2f28a..7bee9c04293ac 100644
--- a/drivers/soc/mediatek/mtk-socinfo.c
+++ b/drivers/soc/mediatek/mtk-socinfo.c
@@ -30,7 +30,6 @@ struct mtk_socinfo {
 	struct device *dev;
 	struct name_data *name_data;
 	struct socinfo_data *socinfo_data;
-	struct soc_device *soc_dev;
 };
 
 struct socinfo_data {
@@ -71,6 +70,7 @@ static int mtk_socinfo_create_socinfo_node(struct mtk_socinfo *mtk_socinfop)
 	struct soc_device_attribute *attrs;
 	struct socinfo_data *data = mtk_socinfop->socinfo_data;
 	static const char *soc_manufacturer = "MediaTek";
+	struct soc_device *soc_dev;
 
 	attrs = devm_kzalloc_obj(mtk_socinfop->dev, *attrs);
 	if (!attrs)
@@ -91,9 +91,9 @@ static int mtk_socinfo_create_socinfo_node(struct mtk_socinfo *mtk_socinfop)
 	 * name from board DTS (if available).
 	 **/
 
-	mtk_socinfop->soc_dev = soc_device_register(attrs);
-	if (IS_ERR(mtk_socinfop->soc_dev))
-		return PTR_ERR(mtk_socinfop->soc_dev);
+	soc_dev = devm_soc_device_register(mtk_socinfop->dev, attrs);
+	if (IS_ERR(soc_dev))
+		return PTR_ERR(soc_dev);
 
 	dev_info(mtk_socinfop->dev, "%s (%s) SoC detected.\n", attrs->family, attrs->soc_id);
 	return 0;
@@ -191,20 +191,11 @@ static int mtk_socinfo_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(mtk_socinfop->dev, ret, "Cannot create node\n");
 
-	platform_set_drvdata(pdev, mtk_socinfop);
 	return 0;
 }
 
-static void mtk_socinfo_remove(struct platform_device *pdev)
-{
-	struct mtk_socinfo *mtk_socinfop = platform_get_drvdata(pdev);
-
-	soc_device_unregister(mtk_socinfop->soc_dev);
-}
-
 static struct platform_driver mtk_socinfo = {
 	.probe = mtk_socinfo_probe,
-	.remove = mtk_socinfo_remove,
 	.driver = {
 		.name = "mtk-socinfo",
 	},
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 07/12] soc: qcom: socinfo: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (5 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 06/12] soc: mediatek: mtk-socinfo: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 08/12] soc: renesas: rz-sysc: " Andrew Davis
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/qcom/socinfo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/soc/qcom/socinfo.c b/drivers/soc/qcom/socinfo.c
index b794ae3b18f56..2f452ba5d675f 100644
--- a/drivers/soc/qcom/socinfo.c
+++ b/drivers/soc/qcom/socinfo.c
@@ -931,7 +931,7 @@ static int qcom_socinfo_probe(struct platform_device *pdev)
 			return -ENOMEM;
 	}
 
-	qs->soc_dev = soc_device_register(&qs->attr);
+	qs->soc_dev = devm_soc_device_register(&pdev->dev, &qs->attr);
 	if (IS_ERR(qs->soc_dev))
 		return PTR_ERR(qs->soc_dev);
 
@@ -949,8 +949,6 @@ static void qcom_socinfo_remove(struct platform_device *pdev)
 {
 	struct qcom_socinfo *qs = platform_get_drvdata(pdev);
 
-	soc_device_unregister(qs->soc_dev);
-
 	socinfo_debugfs_exit(qs);
 }
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 08/12] soc: renesas: rz-sysc: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (6 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 07/12] soc: qcom: socinfo: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 09/12] soc: samsung: exynos-chipid: " Andrew Davis
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/renesas/rz-sysc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/renesas/rz-sysc.c b/drivers/soc/renesas/rz-sysc.c
index 987f826ef09d9..d79e9eee2ff18 100644
--- a/drivers/soc/renesas/rz-sysc.c
+++ b/drivers/soc/renesas/rz-sysc.c
@@ -78,7 +78,7 @@ static int rz_sysc_soc_init(struct rz_sysc *sysc, const struct of_device_id *mat
 			 soc_dev_attr->family, soc_dev_attr->soc_id, soc_dev_attr->revision);
 	}
 
-	soc_dev = soc_device_register(soc_dev_attr);
+	soc_dev = devm_soc_device_register(sysc->dev, soc_dev_attr);
 	if (IS_ERR(soc_dev))
 		return PTR_ERR(soc_dev);
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 09/12] soc: samsung: exynos-chipid: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (7 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 08/12] soc: renesas: rz-sysc: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 10/12] soc: ti: k3-socinfo: " Andrew Davis
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/samsung/exynos-chipid.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/soc/samsung/exynos-chipid.c b/drivers/soc/samsung/exynos-chipid.c
index ad41691cfee87..34ce8a3bfd85a 100644
--- a/drivers/soc/samsung/exynos-chipid.c
+++ b/drivers/soc/samsung/exynos-chipid.c
@@ -146,11 +146,6 @@ static struct regmap *exynos_chipid_get_efuse_regmap(struct platform_device *pde
 	return devm_regmap_init_mmio_clk(&pdev->dev, "pclk", base, &reg_config);
 }
 
-static void exynos_chipid_unregister_soc(void *data)
-{
-	soc_device_unregister(data);
-}
-
 static int exynos_chipid_probe(struct platform_device *pdev)
 {
 	const struct exynos_chipid_variant *drv_data;
@@ -200,16 +195,11 @@ static int exynos_chipid_probe(struct platform_device *pdev)
 		return dev_err_probe(dev, -ENODEV, "Unknown SoC\n");
 
 	/* please note that the actual registration will be deferred */
-	soc_dev = soc_device_register(soc_dev_attr);
+	soc_dev = devm_soc_device_register(dev, soc_dev_attr);
 	if (IS_ERR(soc_dev))
 		return dev_err_probe(dev, PTR_ERR(soc_dev),
 				     "failed to register to the soc interface\n");
 
-	ret = devm_add_action_or_reset(dev, exynos_chipid_unregister_soc,
-				       soc_dev);
-	if (ret)
-		return dev_err_probe(dev, ret, "failed to add devm action\n");
-
 	ret = exynos_asv_init(dev, regmap);
 	if (ret)
 		return ret;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 10/12] soc: ti: k3-socinfo: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (8 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 09/12] soc: samsung: exynos-chipid: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 11/12] soc: versatile: realview: " Andrew Davis
  2026-11-11 17:57 ` [PATCH 12/12] soc: vt8500: " Andrew Davis
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/ti/k3-socinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c
index 48dbef3acceb4..01bd6702c040d 100644
--- a/drivers/soc/ti/k3-socinfo.c
+++ b/drivers/soc/ti/k3-socinfo.c
@@ -218,7 +218,7 @@ static int k3_chipinfo_probe(struct platform_device *pdev)
 	of_property_read_string(node, "model", &soc_dev_attr->machine);
 	of_node_put(node);
 
-	soc_dev = soc_device_register(soc_dev_attr);
+	soc_dev = devm_soc_device_register(dev, soc_dev_attr);
 	if (IS_ERR(soc_dev)) {
 		ret = PTR_ERR(soc_dev);
 		goto err_free_rev;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 11/12] soc: versatile: realview: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (9 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 10/12] soc: ti: k3-socinfo: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  2026-11-11 17:57 ` [PATCH 12/12] soc: vt8500: " Andrew Davis
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/versatile/soc-realview.c | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index addb8eb32f0d9..a0dc37ff9b376 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -82,13 +82,6 @@ static struct attribute *realview_attrs[] = {
 
 ATTRIBUTE_GROUPS(realview);
 
-static void realview_soc_socdev_release(void *data)
-{
-	struct soc_device *soc_dev = data;
-
-	soc_device_unregister(soc_dev);
-}
-
 static int realview_soc_probe(struct platform_device *pdev)
 {
 	struct regmap *syscon_regmap;
@@ -113,15 +106,10 @@ static int realview_soc_probe(struct platform_device *pdev)
 	soc_dev_attr->machine = "RealView";
 	soc_dev_attr->family = "Versatile";
 	soc_dev_attr->custom_attr_group = realview_groups[0];
-	soc_dev = soc_device_register(soc_dev_attr);
+	soc_dev = devm_soc_device_register(&pdev->dev, soc_dev_attr);
 	if (IS_ERR(soc_dev))
 		return -ENODEV;
 
-	ret = devm_add_action_or_reset(&pdev->dev, realview_soc_socdev_release,
-				       soc_dev);
-	if (ret)
-		return ret;
-
 	ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET,
 			  &realview_coreid);
 	if (ret)
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 12/12] soc: vt8500: Use devm_soc_device_register() helper
  2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
                   ` (10 preceding siblings ...)
  2026-11-11 17:57 ` [PATCH 11/12] soc: versatile: realview: " Andrew Davis
@ 2026-11-11 17:57 ` Andrew Davis
  11 siblings, 0 replies; 13+ messages in thread
From: Andrew Davis @ 2026-11-11 17:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich, Johan Hovold
  Cc: driver-core, linux-kernel, Andrew Davis

Use the device lifecycle managed register function. This helps prevent
mistakes like unregistering out of order in cleanup functions and
forgetting to unregister on error paths.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/soc/vt8500/wmt-socinfo.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/soc/vt8500/wmt-socinfo.c b/drivers/soc/vt8500/wmt-socinfo.c
index e514c98a796fc..49c92e993a45e 100644
--- a/drivers/soc/vt8500/wmt-socinfo.c
+++ b/drivers/soc/vt8500/wmt-socinfo.c
@@ -84,7 +84,7 @@ static int wmt_socinfo_probe(struct platform_device *pdev)
 	if (!attrs->revision || !attrs->soc_id)
 		return -ENOMEM;
 
-	soc_dev = soc_device_register(attrs);
+	soc_dev = devm_soc_device_register(&pdev->dev, attrs);
 	if (IS_ERR(soc_dev))
 		return PTR_ERR(soc_dev);
 
@@ -94,17 +94,9 @@ static int wmt_socinfo_probe(struct platform_device *pdev)
 		 attrs->revision,
 		 attrs->soc_id);
 
-	platform_set_drvdata(pdev, soc_dev);
 	return 0;
 }
 
-static void wmt_socinfo_remove(struct platform_device *pdev)
-{
-	struct soc_device *soc_dev = platform_get_drvdata(pdev);
-
-	soc_device_unregister(soc_dev);
-}
-
 static const struct of_device_id wmt_socinfo_ids[] = {
 	{ .compatible = "via,vt8500-scc-id" },
 	{ /* Sentinel */ },
@@ -112,7 +104,6 @@ static const struct of_device_id wmt_socinfo_ids[] = {
 
 static struct platform_driver wmt_socinfo = {
 	.probe = wmt_socinfo_probe,
-	.remove = wmt_socinfo_remove,
 	.driver = {
 		.name = "wmt-socinfo",
 		.of_match_table = wmt_socinfo_ids,
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-11-11 17:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 17:56 [PATCH 00/12] Add and use DEVM soc_device_register helper Andrew Davis
2026-11-11 17:57 ` [PATCH 01/12] base: soc: Implement devm_soc_device_register() helper function Andrew Davis
2026-11-11 17:57 ` [PATCH 02/12] soc: ep93xx: Use devm_soc_device_register() helper Andrew Davis
2026-11-11 17:57 ` [PATCH 03/12] soc: imx8m: " Andrew Davis
2026-11-11 17:57 ` [PATCH 04/12] soc: imx9: " Andrew Davis
2026-11-11 17:57 ` [PATCH 05/12] soc: loongson: " Andrew Davis
2026-11-11 17:57 ` [PATCH 06/12] soc: mediatek: mtk-socinfo: " Andrew Davis
2026-11-11 17:57 ` [PATCH 07/12] soc: qcom: socinfo: " Andrew Davis
2026-11-11 17:57 ` [PATCH 08/12] soc: renesas: rz-sysc: " Andrew Davis
2026-11-11 17:57 ` [PATCH 09/12] soc: samsung: exynos-chipid: " Andrew Davis
2026-11-11 17:57 ` [PATCH 10/12] soc: ti: k3-socinfo: " Andrew Davis
2026-11-11 17:57 ` [PATCH 11/12] soc: versatile: realview: " Andrew Davis
2026-11-11 17:57 ` [PATCH 12/12] soc: vt8500: " Andrew Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®