clk: clk-divider: Export clk_register_divider()
PATCH 1/1 clk: clk-divider: Export clk_register_divider()
From: Fabio Estevam <[email protected]>
clk_register_divider() needs to be exported so that it could be used in a module driver, otherwise we get the following error:
ERROR: "clk_register_divider" [sound/soc/mxs/snd-soc-mxs.ko] undefined!
--- drivers/clk/clk-divider.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/clk-divider.c +1 -0
@@ -317,6 +317,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags,NULL , lock); } +EXPORT_SYMBOL_GPL (clk_register_divider);/** * clk_register_divider_table - register a table based divider clock with
Signature · 1 line
1.8.1.2
PATCH 1/1 clk: clk-divider: Export clk_register_divider()
Hi,
Quoted 18 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
clk_register_divider()needs to be exported so that it could be used in a module driver, otherwise we get the following error:ERROR: "
clk_register_divider" [sound/soc/mxs/snd-soc-mxs.ko] undefined!Signed-off-by Fabio Estevam <[email protected]>--- drivers/clk/clk-divider.c | 1 + 1 file changed, 1 insertion(+)drivers/clk/clk-divider.c +0
-0
drivers/clk/clk-divider.c struct clk *clk_register_divider(struct device *dev, const char *name, · line 323
Quoted 7 lines
drivers/clk/clk-divider.c +1
-0@@ -317,6 +317,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags,NULL , lock); } +EXPORT_SYMBOL_GPL (clk_register_divider);/** * clk_register_divider_table - register a table based divider clock with
Did you try unloading and reloading the module with this patch?
The registered clock divider will not be deregistered, but will be reused upon reload, still using the old (now unmapped) address to access the clk registers. Thus the whole approach used in snd-soc-mxs is broken by design (at least for modules).
You would need to keep the mapping of the base registers established upon the first module load to let the clock divider registered from the first module load stay operational across module unload/load.
I already considered creating a patch for this, but the whole approach seemed me too crappy to submit it to mainline.
Lothar Wa?mann
Signature · 9 lines
___________________________________________________________ Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10 Gesch?ftsf?hrer: Matthias Kaussen Handelsregistereintrag: Amtsgericht Aachen, HRB 4996 www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
PATCH 1/1 clk: clk-divider: Export clk_register_divider()
Hi,
Quoted 28 lines · Lothar Wa?mann
Quoted 18 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
clk_register_divider()needs to be exported so that it could be used in a module driver, otherwise we get the following error:ERROR: "
clk_register_divider" [sound/soc/mxs/snd-soc-mxs.ko] undefined!Signed-off-by Fabio Estevam <[email protected]>--- drivers/clk/clk-divider.c | 1 + 1 file changed, 1 insertion(+)drivers/clk/clk-divider.c +0
-0drivers/clk/clk-divider.c struct clk *clk_register_divider(struct device *dev, const char *name, · line 323
Quoted 7 lines
drivers/clk/clk-divider.c +1
-0@@ -317,6 +317,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags,NULL , lock); } +EXPORT_SYMBOL_GPL (clk_register_divider);/** * clk_register_divider_table - register a table based divider clock with Did you try unloading and reloading the module with this patch?
Quoted 8 lines
The registered clock divider will not be deregistered, but will be reused upon reload, still using the old (now unmapped) address to access the clk registers. Thus the whole approach used in snd-soc-mxs is broken by design (at least for modules).
You would need to keep the mapping of the base registers established upon the first module load to let the clock divider registered from the first module load stay operational across module unload/load.
Not sure this is a good idea, clock supplier should unregister its clocks upon module removal.
Quoted 2 lines
I already considered creating a patch for this, but the whole approach seemed me too crappy to submit it to mainline.
I have been working on adding support for the clocks unregistration, currently only clk_unregister(), following discussion [1] and based a little on patch [2]. I'll try to post what I currently have as an RFC on Monday.
I've added __clk_get(), __clk_put() for the common clock API implementation. These functions take reference on the clock supplier module, but there is also plain reference counting so memory allocated for the clock object is freed when last consumer calls clk_put() on the clock. This is mainly to avoid a disaster in cases when driver is unbound through "unbind" sysfs attribute, the module is not unloaded but the driver's remove() callback is invoked - which causes the clock to be unregistered.
My use case is that an SoC camera host interface provides clock for external image sensor driver, and since the host interface driver is a LKM this can't work without proper clock unregistration support.
[1] http://www.spinics.net/lists/arm-kernel/msg258387.html
[2] http://www.spinics.net/lists/arm-kernel/msg247548.html
Thanks,
Sylwester
PATCH 1/1 clk: clk-divider: Export clk_register_divider()
In reply to Lothar WaßmannQuoted 30 lines · Lothar Wa?mann
Hi,
Quoted 18 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
clk_register_divider()needs to be exported so that it could be used in a module driver, otherwise we get the following error:ERROR: "
clk_register_divider" [sound/soc/mxs/snd-soc-mxs.ko] undefined!Signed-off-by Fabio Estevam <[email protected]>--- drivers/clk/clk-divider.c | 1 + 1 file changed, 1 insertion(+)drivers/clk/clk-divider.c +0
-0drivers/clk/clk-divider.c struct clk *clk_register_divider(struct device *dev, const char *name, · line 323
Quoted 7 lines
drivers/clk/clk-divider.c +1
-0@@ -317,6 +317,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags,NULL , lock); } +EXPORT_SYMBOL_GPL (clk_register_divider);/** * clk_register_divider_table - register a table based divider clock with Did you try unloading and reloading the module with this patch?
Quoted 4 lines
The registered clock divider will not be deregistered, but will be reused upon reload, still using the old (now unmapped) address to access the clk registers. Thus the whole approach used in snd-soc-mxs is broken by design (at least for modules).
It's just an immediate stop-gap fix to the failure of devm_clk_get() in sgtl5000 driver. The register access will only happen when clk_*_rate() is called on the clock, since it's a divider clock. Yeah, I have to admit it's dirty, but it shouldn't cause any problem for now, because sgtl5000 driver does not do any clk_*_rate() calls so far.
Quoted 7 lines
You would need to keep the mapping of the base registers established upon the first module load to let the clock divider registered from the first module load stay operational across module unload/load.
I already considered creating a patch for this, but the whole approach seemed me too crappy to submit it to mainline.
I agree with Sylwester. Clock framework should support deregistration.
Shawn
PATCH 1/1 clk: clk-divider: Export clk_register_divider()
In reply to Fabio EstevamQuoting Fabio Estevam (2013-08-02 09:14:07)
Quoted 26 lines
From: Fabio Estevam <[email protected]>
clk_register_divider()needs to be exported so that it could be used in a module driver, otherwise we get the following error:ERROR: "
clk_register_divider" [sound/soc/mxs/snd-soc-mxs.ko] undefined!Signed-off-by Fabio Estevam <[email protected]>--- drivers/clk/clk-divider.c | 1 + 1 file changed, 1 insertion(+)drivers/clk/clk-divider.c +1
-0@@ -317,6 +317,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags,NULL , lock); } +EXPORT_SYMBOL_GPL (clk_register_divider);/** * clk_register_divider_table - register a table based divider clock with Signature · 1 line
1.8.1.2
Taken into clk-next. I also exported clk_register_divider_table. Updated patch below:
Quoted 1 line
From
43cf78b2d87c525d009515c936e4ad2c6c7cfc24Mon Sep 17 00:00:00 2001
From: Fabio Estevam <[email protected]>
Date: Fri, 2 Aug 2013 13:14:07 -0300
Subject: [PATCH] clk: clk-divider: Export clk_register_divider()
clk_register_divider() needs to be exported so that it could be used in a module driver, otherwise we get the following error:
ERROR: "clk_register_divider" [sound/soc/mxs/snd-soc-mxs.ko] undefined!
--- drivers/clk/clk-divider.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/clk-divider.c +2 -0
@@ -317,6 +317,7 @@ struct clk *clk_register_divider(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags,NULL , lock); } +EXPORT_SYMBOL_GPL (clk_register_divider);/** * clk_register_divider_table - register a table based divider clock with
@@ -341,3 +342,4 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name,return _register_divider (dev, name, parent_name, flags, reg, shift, width, clk_divider_flags, table, lock); } +EXPORT_SYMBOL_GPL (clk_register_divider_table);
Signature · 1 line
1.8.1.2