stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] clk: s2mps11: Fix matching when built as module and DT node contains compatible
       [not found] <20180725155517.4872-1-krzk@kernel.org>
@ 2018-07-25 15:55 ` Krzysztof Kozlowski
  2018-07-25 23:48   ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2018-07-25 15:55 UTC (permalink / raw)
  To: Rob Herring, Mark Rutland, Kukjin Kim, Krzysztof Kozlowski,
	Sangbeom Kim, Bartlomiej Zolnierkiewicz, Michael Turquette,
	Stephen Boyd, devicetree, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, linux-clk
  Cc: stable

When driver is built as module and DT node contains clocks compatible
(e.g. "samsung,s2mps11-clk"), the module will not be autoloaded because
module aliases won't match.

The modalias from uevent: of:NclocksT<NULL>Csamsung,s2mps11-clk
The modalias from driver: platform:s2mps11-clk

The devices are instantiated by parent's MFD.  However both Device Tree
bindings and parent define the compatible for clocks devices.  In case
of module matching this DT compatible will be used.

The issue will not happen if this is built-in (no need for module
matching) or when clocks DT node does not contain compatible (not
correct from bindings perspective but working for driver).

Note when backporting to stable kernels: adjust the list of device ID
entries.

Cc: <stable@vger.kernel.org>
Fixes: 53c31b3437a6 ("mfd: sec-core: Add of_compatible strings for clock MFD cells")
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/clk/clk-s2mps11.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index d44e0eea31ec..11a1e83ff805 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -245,6 +245,36 @@ static const struct platform_device_id s2mps11_clk_id[] = {
 };
 MODULE_DEVICE_TABLE(platform, s2mps11_clk_id);
 
+#ifdef CONFIG_OF
+/*
+ * Device is instantiated through parent MFD device and device matching is done
+ * through platform_device_id.
+ *
+ * However if device's DT node contains proper clock compatible and it is built
+ * as a module, then the module matching will be done trough DT aliases.  This
+ * requires of_device_id table.  In the same time this will not change the
+ * actual device matching so do not add .of_match_table.
+ */
+static const struct of_device_id s2mps11_dt_match[] = {
+	{
+		.compatible = "samsung,s2mps11-clk",
+		.data = (void *)S2MPS11X,
+	}, {
+		.compatible = "samsung,s2mps13-clk",
+		.data = (void *)S2MPS13X,
+	}, {
+		.compatible = "samsung,s2mps14-clk",
+		.data = (void *)S2MPS14X,
+	}, {
+		.compatible = "samsung,s5m8767-clk",
+		.data = (void *)S5M8767X,
+	}, {
+		/* Sentinel */
+	},
+};
+MODULE_DEVICE_TABLE(of, s2mps11_dt_match);
+#endif
+
 static struct platform_driver s2mps11_clk_driver = {
 	.driver = {
 		.name  = "s2mps11-clk",
-- 
2.14.1

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

* Re: [PATCH 1/3] clk: s2mps11: Fix matching when built as module and DT node contains compatible
  2018-07-25 15:55 ` [PATCH 1/3] clk: s2mps11: Fix matching when built as module and DT node contains compatible Krzysztof Kozlowski
@ 2018-07-25 23:48   ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2018-07-25 23:48 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, Krzysztof Kozlowski, Kukjin Kim,
	Mark Rutland, Michael Turquette, Rob Herring, Sangbeom Kim,
	devicetree, linux-arm-kernel, linux-clk, linux-kernel,
	linux-samsung-soc
  Cc: stable

Quoting Krzysztof Kozlowski (2018-07-25 08:55:15)
> When driver is built as module and DT node contains clocks compatible
> (e.g. "samsung,s2mps11-clk"), the module will not be autoloaded because
> module aliases won't match.
> 
> The modalias from uevent: of:NclocksT<NULL>Csamsung,s2mps11-clk
> The modalias from driver: platform:s2mps11-clk
> 
> The devices are instantiated by parent's MFD.  However both Device Tree
> bindings and parent define the compatible for clocks devices.  In case
> of module matching this DT compatible will be used.
> 
> The issue will not happen if this is built-in (no need for module
> matching) or when clocks DT node does not contain compatible (not
> correct from bindings perspective but working for driver).
> 
> Note when backporting to stable kernels: adjust the list of device ID
> entries.
> 
> Cc: <stable@vger.kernel.org>
> Fixes: 53c31b3437a6 ("mfd: sec-core: Add of_compatible strings for clock MFD cells")
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---

Acked-by: Stephen Boyd <sboyd@kernel.org>

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

end of thread, other threads:[~2018-07-26  1:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180725155517.4872-1-krzk@kernel.org>
2018-07-25 15:55 ` [PATCH 1/3] clk: s2mps11: Fix matching when built as module and DT node contains compatible Krzysztof Kozlowski
2018-07-25 23:48   ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).