linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: sun6i: Fix compatibility with old DT binding
@ 2017-01-29 10:13 Chen-Yu Tsai
  2017-01-31 21:05 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Chen-Yu Tsai @ 2017-01-29 10:13 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, Maxime Ripard
  Cc: Chen-Yu Tsai, rtc-linux, linux-arm-kernel, linux-kernel

Commit 847b8bf62eb4 ("rtc: sun6i: Expose the 32kHz oscillator") adds
a new clock for the rtc block with a 2 step probe mechanism. To share
the register region between both the clock and rtc instance, a static
pointer is used to keep the related data structure.

To preserve compatibility with the old binding, the data structure
should be saved as soon as the registers are mapped in, regardless
of the presence of the clock bindings, so that the rtc device can
retrieve it when it is probed.

This fixes the rtc device not probing when we use the updated driver
with an old device tree blob.

Fixes: 847b8bf62eb4 ("rtc: sun6i: Expose the 32kHz oscillator")
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/rtc/rtc-sun6i.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
index 613f42ade533..08510ca58996 100644
--- a/drivers/rtc/rtc-sun6i.c
+++ b/drivers/rtc/rtc-sun6i.c
@@ -211,6 +211,9 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
 	writel(SUN6I_LOSC_CTRL_KEY | SUN6I_LOSC_CTRL_EXT_OSC,
 	       rtc->base + SUN6I_LOSC_CTRL);
 
+	/* Yes, I know, this is ugly. */
+	sun6i_rtc = rtc;
+
 	/* Deal with old DTs */
 	if (!of_get_property(node, "clocks", NULL))
 		return;
@@ -243,9 +246,6 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
 	clk_data->num = 1;
 	clk_data->hws[0] = &rtc->hw;
 	of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
-
-	/* Yes, I know, this is ugly. */
-	sun6i_rtc = rtc;
 }
 CLK_OF_DECLARE_DRIVER(sun6i_rtc_clk, "allwinner,sun6i-a31-rtc",
 		      sun6i_rtc_clk_init);
-- 
2.11.0

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

* Re: [PATCH] rtc: sun6i: Fix compatibility with old DT binding
  2017-01-29 10:13 [PATCH] rtc: sun6i: Fix compatibility with old DT binding Chen-Yu Tsai
@ 2017-01-31 21:05 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2017-01-31 21:05 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Alessandro Zummo, Maxime Ripard, rtc-linux, linux-arm-kernel,
	linux-kernel

On 29/01/2017 at 18:13:43 +0800, Chen-Yu Tsai wrote:
> Commit 847b8bf62eb4 ("rtc: sun6i: Expose the 32kHz oscillator") adds
> a new clock for the rtc block with a 2 step probe mechanism. To share
> the register region between both the clock and rtc instance, a static
> pointer is used to keep the related data structure.
> 
> To preserve compatibility with the old binding, the data structure
> should be saved as soon as the registers are mapped in, regardless
> of the presence of the clock bindings, so that the rtc device can
> retrieve it when it is probed.
> 
> This fixes the rtc device not probing when we use the updated driver
> with an old device tree blob.
> 
> Fixes: 847b8bf62eb4 ("rtc: sun6i: Expose the 32kHz oscillator")
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  drivers/rtc/rtc-sun6i.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

end of thread, other threads:[~2017-01-31 21:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-29 10:13 [PATCH] rtc: sun6i: Fix compatibility with old DT binding Chen-Yu Tsai
2017-01-31 21:05 ` Alexandre Belloni

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).