make clk_get_rate implementations behavior more consistent
Subsystems (9)
cover make clk_get_rate implementations behavior more consistent
The common clock and several other clock API implementations allow calling clk_get_rate with a NULL pointer. While not specified as expected behavior of the API, device drivers have come to rely on that, causing them to OOPS when run on a platform with a different clock API implementation.
Fix this by making sure all clk_get_rate implementations handle NULL clocks instead of OOPSing.
While some custom implementations even allow ERR_PTR()s, I decided against that as IIRC the usual idea is that errors should be handled and not silently carried over.
Jonas Gorski (9):
ARM: ep93xx: allow NULL clock for clk_get_rate
ARM: mmp: allow NULL clock for clk_get_rate
blackfin: bf609: allow NULL clock for clk_get_rate
m68k: allow NULL clock for clk_get_rate
MIPS: AR7: allow NULL clock for clk_get_rate
MIPS: BCM63XX: allow NULL clock for clk_get_rate
MIPS: Loongson 2F: allow NULL clock for clk_get_rate
MIPS: ralink: allow NULL clock for clk_get_rate
unicore32: allow NULL clock for clk_get_rate
arch/arm/mach-ep93xx/clock.c | 3 +++ arch/arm/mach-mmp/clock.c | 4 +++- arch/blackfin/mach-bf609/clock.c | 2 +- arch/m68k/coldfire/clk.c | 3 +++ arch/mips/ar7/clock.c | 3 +++ arch/mips/bcm63xx/clk.c | 3 +++ arch/mips/loongson64/lemote-2f/clock.c | 3 +++ arch/mips/ralink/clk.c | 3 +++ arch/unicore32/kernel/clock.c | 3 +++ 9 files changed, 25 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/9 ARM: ep93xx: allow NULL clock for clk_get_rate
Make the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/arm/mach-ep93xx/clock.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mach-ep93xx/clock.c +3 -0
@@ -316,6 +316,9 @@ static unsigned long get_uart_rate(struct clk *clk)unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +if (clk->get_rate)return clk->get_rate (clk);
Signature · 1 line
2.11.0
Re: [PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate
Quoted 4 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
Quoted 8 lines
Fixes 1d81eedb8f6c ("[ARM] 3634/1: ep93xx: initial implementation of the clk_* API")Cc Hartley Sweeten <[email protected]>Cc Alexander Sverdlin <[email protected]>Cc Russell King <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgReported-by Mathias Kresin <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Quoted 17 lines
--- arch/arm/mach-ep93xx/clock.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/mach-ep93xx/clock.c +3
-0@@ -316,6 +316,9 @@ static unsigned long get_uart_rate(struct clk *clk)unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +if (clk->get_rate)return clk->get_rate (clk);
PATCH 2/9 ARM: mmp: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/arm/mach-mmp/clock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-mmp/clock.c +3 -1
@@ -83,7 +83,9 @@ unsigned long clk_get_rate(struct clk *clk) {unsigned long rate; -if (clk->ops->getrate) +if (!clk) + rate =0 ; +else if (clk->ops->getrate) rate = clk->ops->getrate (clk);else rate = clk->rate;
Signature · 1 line
2.11.0
PATCH 3/9 blackfin: bf609: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/blackfin/mach-bf609/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/blackfin/mach-bf609/clock.c +1 -1
@@ -109,7 +109,7 @@ EXPORT_SYMBOL(clk_disable);unsigned long clk_get_rate (struct clk *clk) {unsigned long ret =0 ; -if (clk->ops && clk->ops->get_rate) +if (clk && clk->ops && clk->ops->get_rate) ret = clk->ops->get_rate (clk);return ret; }
Signature · 1 line
2.11.0
Re: [PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate
2017-07-18 19:17 GMT+09:00 Jonas Gorski <[email protected]>:
Quoted 7 lines
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.Fixes 969003152aa9 ("blackfin: bf60x: add clock support")Cc Steven Miao <[email protected]>Cc Masahiro Yamada <[email protected]>
This Cc can be replaced with
Thank you.
Quoted 25 lines
Cc Andrew Morton <[email protected]>Reported-by Mathias Kresin <[email protected]>Signed-off-by Jonas Gorski <[email protected]>--- arch/blackfin/mach-bf609/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/blackfin/mach-bf609/clock.c +1
-2@@ -109,7 +109,7 @@ EXPORT_SYMBOL(clk_disable);unsigned long clk_get_rate (struct clk *clk) {unsigned long ret =0 ; -if (clk->ops && clk->ops->get_rate) +if (clk && clk->ops && clk->ops->get_rate) ret = clk->ops->get_rate (clk);return ret; } --2.11.0
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH 4/9 m68k: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/m68k/coldfire/clk.c | 3 +++ 1 file changed, 3 insertions(+)
arch/m68k/coldfire/clk.c +3 -0
@@ -121,6 +121,9 @@ EXPORT_SYMBOL(clk_put);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }EXPORT_SYMBOL (clk_get_rate);
Signature · 1 line
2.11.0
PATCH 4/9 m68k: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/m68k/coldfire/clk.c | 3 +++ 1 file changed, 3 insertions(+)
arch/m68k/coldfire/clk.c +3 -0
@@ -121,6 +121,9 @@ EXPORT_SYMBOL(clk_put);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }EXPORT_SYMBOL (clk_get_rate);
Signature · 1 line
2.11.0
Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Hi Jonas,
Quoted 6 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.Fixes facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")Cc Greg Ungerer <[email protected]>
Do you want me to push this via the m68knommu git tree? Or are you (or someone) taking the series as a whole?
Regards
Greg
Quoted 24 lines
Cc Geert Uytterhoeven <[email protected]>Reported-by Mathias Kresin <[email protected]>Signed-off-by Jonas Gorski <[email protected]>--- arch/m68k/coldfire/clk.c | 3 +++ 1 file changed, 3 insertions(+)arch/m68k/coldfire/clk.c +3
-0@@ -121,6 +121,9 @@ EXPORT_SYMBOL(clk_put);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }EXPORT_SYMBOL (clk_get_rate);
Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Hi Greg,
Quoted 8 lines · Greg Ungerer
Hi Jonas,
Quoted 5 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
Quoted 8 lines
Quoted 2 lines
Fixes facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")Cc Greg Ungerer <[email protected]>Acked-by Greg Ungerer <[email protected]>Do you want me to push this via the m68knommu git tree? Or are you (or someone) taking the series as a whole?
Please take it through your tree. I totally forgot mentioning in the cover letter that I'm just a simple patch submitter and don't have my own tree. Too long ago that I sent a multi-tree patch series last time ... .
Regards
Jonas
Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
In reply to Greg UngererHi Greg,
Quoted 8 lines · Greg Ungerer
Hi Jonas,
Quoted 5 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
Quoted 8 lines
Quoted 2 lines
Fixes facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")Cc Greg Ungerer <[email protected]>Acked-by Greg Ungerer <[email protected]>Do you want me to push this via the m68knommu git tree? Or are you (or someone) taking the series as a whole?
Please take it through your tree. I totally forgot mentioning in the cover letter that I'm just a simple patch submitter and don't have my own tree. Too long ago that I sent a multi-tree patch series last time ... .
Regards
Jonas
Greg Ungerer
maintainerRe: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Hi Jonas,
Quoted 15 lines · Jonas Gorski
Hi Greg,
Quoted 12 lines · Greg Ungerer
Hi Jonas,
Quoted 7 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.Fixes facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")Cc Greg Ungerer <[email protected]>
Quoted 8 lines
Quoted 4 lines
Acked-by Greg Ungerer <[email protected]>Do you want me to push this via the m68knommu git tree? Or are you (or someone) taking the series as a whole?
Please take it through your tree. I totally forgot mentioning in the cover letter that I'm just a simple patch submitter and don't have my own tree. Too long ago that I sent a multi-tree patch series last time
No problem. Added to the m68knommu git tree, for-next branch.
Thanks
Greg
Greg Ungerer
maintainerRe: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
In reply to Jonas GorskiHi Jonas,
Quoted 15 lines · Jonas Gorski
Hi Greg,
Quoted 12 lines · Greg Ungerer
Hi Jonas,
Quoted 7 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.Fixes facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")Cc Greg Ungerer <[email protected]>
Quoted 8 lines
Quoted 4 lines
Acked-by Greg Ungerer <[email protected]>Do you want me to push this via the m68knommu git tree? Or are you (or someone) taking the series as a whole?
Please take it through your tree. I totally forgot mentioning in the cover letter that I'm just a simple patch submitter and don't have my own tree. Too long ago that I sent a multi-tree patch series last time
No problem. Added to the m68knommu git tree, for-next branch.
Thanks
Greg
PATCH 5/9 MIPS: AR7: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/mips/ar7/clock.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/ar7/clock.c +3 -0
@@ -430,6 +430,9 @@ EXPORT_SYMBOL(clk_disable);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }EXPORT_SYMBOL (clk_get_rate);
Signature · 1 line
2.11.0
PATCH 6/9 MIPS: BCM63XX: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/mips/bcm63xx/clk.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/bcm63xx/clk.c +3 -0
@@ -339,6 +339,9 @@ EXPORT_SYMBOL(clk_disable);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }
Signature · 1 line
2.11.0
Re: [PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate
Quoted 4 lines · Jonas Gorski
Make the behaviour of
clk_get_rateconsistent with common clk'sclk_get_rateby accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
Quoted 9 lines
Fixes e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")Cc Ralf Baechle <[email protected]>Cc Florian Fainelli <[email protected]>Cc James Hogan <[email protected]>Reported-by Mathias Kresin <[email protected]>Signed-off-by Jonas Gorski <[email protected]>
Signature · 1 line
Florian
PATCH 7/9 MIPS: Loongson 2F: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter, as some device drivers rely on this.
Make the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/mips/loongson64/lemote-2f/clock.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/loongson64/lemote-2f/clock.c +3 -0
@@ -80,6 +80,9 @@ EXPORT_SYMBOL(clk_disable);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return (unsigned long )clk->rate; }EXPORT_SYMBOL (clk_get_rate);
Signature · 1 line
2.11.0
PATCH 8/9 MIPS: ralink: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/mips/ralink/clk.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/ralink/clk.c +3 -0
@@ -53,6 +53,9 @@ EXPORT_SYMBOL_GPL(clk_disable);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }EXPORT_SYMBOL_GPL (clk_get_rate);
Signature · 1 line
2.11.0
PATCH 9/9 unicore32: allow NULL clock for clk_get_rate
In reply to Jonas GorskiMake the behaviour of clk_get_rate consistent with common clk's clk_get_rate by accepting NULL clocks as parameter. Some device drivers rely on this, and will cause an OOPS otherwise.
--- arch/unicore32/kernel/clock.c | 3 +++ 1 file changed, 3 insertions(+)
arch/unicore32/kernel/clock.c +3 -0
@@ -92,6 +92,9 @@ EXPORT_SYMBOL(clk_disable);unsigned long clk_get_rate (struct clk *clk) { +if (!clk) +return 0 ; +return clk->rate; }EXPORT_SYMBOL (clk_get_rate);
Signature · 1 line
2.11.0
Hi Jonas,
Quoted 31 lines · Jonas Gorski
The common clock and several other clock API implementations allow calling
clk_get_ratewith a NULL pointer. While not specified as expected behavior of the API, device drivers have come to rely on that, causing them to OOPS when run on a platform with a different clock API implementation.Fix this by making sure all
clk_get_rateimplementations handle NULL clocks instead of OOPSing.While some custom implementations even allow ERR_PTR()s, I decided against that as IIRC the usual idea is that errors should be handled and not silently carried over.
Cc adi-buildroot-devel at lists.sourceforge.netCc bcm-kernel-feedback-list at broadcom.comCc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgCc linux-m68k at lists.linux-m68k.orgCc linux-mips at linux-mips.orgJonas Gorski (9):
ARM: ep93xx: allow NULL clock forclk_get_rate
ARM: mmp: allow NULL clock forclk_get_rate
blackfin: bf609: allow NULL clock forclk_get_rate
m68k: allow NULL clock forclk_get_rate
MIPS: AR7: allow NULL clock forclk_get_rate
MIPS: BCM63XX: allow NULL clock forclk_get_rate
MIPS: Loongson 2F: allow NULL clock forclk_get_rate
MIPS: ralink: allow NULL clock forclk_get_rate
unicore32: allow NULL clock forclk_get_rate
Quoted 10 lines
arch/arm/mach-ep93xx/clock.c | 3 +++ arch/arm/mach-mmp/clock.c | 4 +++- arch/blackfin/mach-bf609/clock.c | 2 +- arch/m68k/coldfire/clk.c | 3 +++ arch/mips/ar7/clock.c | 3 +++ arch/mips/bcm63xx/clk.c | 3 +++ arch/mips/loongson64/lemote-2f/clock.c | 3 +++ arch/mips/ralink/clk.c | 3 +++ arch/unicore32/kernel/clock.c | 3 +++ 9 files changed, 25 insertions(+), 2 deletions(-)
For the whole series:
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds