Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1690013 > unrolled thread

[PATCH 0/9] make clk_get_rate implementations behavior more consistent

Started byJonas Gorski <jonas.gorski@gmail.com>
First post2017-07-18 12:20 +0200
Last post2017-07-18 14:10 +0200
Articles 16 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/9] make clk_get_rate implementations behavior more consistent Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
    [PATCH 2/9] ARM: mmp: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
    [PATCH 4/9] m68k: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
      Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate Greg Ungerer <gerg@linux-m68k.org> - 2017-07-18 14:10 +0200
        Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-19 11:10 +0200
          Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate Greg Ungerer <gerg@linux-m68k.org> - 2017-07-19 14:30 +0200
    [PATCH 5/9] MIPS: AR7: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
    [PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
      Re: [PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate Florian Fainelli <f.fainelli@gmail.com> - 2017-07-18 22:00 +0200
    [PATCH 9/9] unicore32: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
    [PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
      Re: [PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate Masahiro Yamada <yamada.masahiro@socionext.com> - 2017-07-18 21:00 +0200
    [PATCH 7/9] MIPS: Loongson 2F: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
    [PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate Jonas Gorski <jonas.gorski@gmail.com> - 2017-07-18 12:20 +0200
      Re: [PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate Alexander Sverdlin <alexander.sverdlin@gmail.com> - 2017-07-19 07:10 +0200
    Re: [PATCH 0/9] make clk_get_rate implementations behavior more consistent Geert Uytterhoeven <geert@linux-m68k.org> - 2017-07-18 14:10 +0200

#1690013 — [PATCH 0/9] make clk_get_rate implementations behavior more consistent

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 0/9] make clk_get_rate implementations behavior more consistent
Message-ID<u4xLH-17C-3@gated-at.bofh.it>
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.

Cc: adi-buildroot-devel@lists.sourceforge.net
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-mips@linux-mips.org

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

-- 
2.11.0

[toc] | [next] | [standalone]


#1690014 — [PATCH 2/9] ARM: mmp: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 2/9] ARM: mmp: allow NULL clock for clk_get_rate
Message-ID<u4xLH-17C-11@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: 49cbe78637eb ("[ARM] pxa: add base support for Marvell's PXA168 processor line")
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/arm/mach-mmp/clock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-mmp/clock.c b/arch/arm/mach-mmp/clock.c
index 28fe64c6e2f5..bdfb113431ec 100644
--- a/arch/arm/mach-mmp/clock.c
+++ b/arch/arm/mach-mmp/clock.c
@@ -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;
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690016 — [PATCH 4/9] m68k: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Message-ID<u4xLH-17C-13@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/m68k/coldfire/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
index 1e3c7e9193d1..856069a3196d 100644
--- a/arch/m68k/coldfire/clk.c
+++ b/arch/m68k/coldfire/clk.c
@@ -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);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690209 — Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate

FromGreg Ungerer <gerg@linux-m68k.org>
Date2017-07-18 14:10 +0200
SubjectRe: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Message-ID<u4zua-2f6-15@gated-at.bofh.it>
In reply to#1690016
Hi Jonas,

On 18/07/17 20:17, Jonas Gorski wrote:
> 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.
> 
> Fixes: facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")
> Cc: Greg Ungerer <gerg@linux-m68k.org>

Acked-by: Greg Ungerer <gerg@linux-m68k.org>

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



> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-kernel@vger.kernel.org
> Reported-by: Mathias Kresin <dev@kresin.me>
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
> ---
>   arch/m68k/coldfire/clk.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c
> index 1e3c7e9193d1..856069a3196d 100644
> --- a/arch/m68k/coldfire/clk.c
> +++ b/arch/m68k/coldfire/clk.c
> @@ -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);
> 

[toc] | [prev] | [next] | [standalone]


#1691145 — Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-19 11:10 +0200
SubjectRe: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Message-ID<u4T9x-6rf-41@gated-at.bofh.it>
In reply to#1690209
Hi Greg,

On 18 July 2017 at 14:03, Greg Ungerer <gerg@linux-m68k.org> wrote:
> Hi Jonas,
>
> On 18/07/17 20:17, Jonas Gorski wrote:
>>
>> 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.
>>
>> Fixes: facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")
>> Cc: Greg Ungerer <gerg@linux-m68k.org>
>
>
> Acked-by: Greg Ungerer <gerg@linux-m68k.org>
>
> 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

[toc] | [prev] | [next] | [standalone]


#1691639 — Re: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate

FromGreg Ungerer <gerg@linux-m68k.org>
Date2017-07-19 14:30 +0200
SubjectRe: [PATCH 4/9] m68k: allow NULL clock for clk_get_rate
Message-ID<u4Wh5-8vz-31@gated-at.bofh.it>
In reply to#1691145
Hi Jonas,

On 19/07/17 19:06, Jonas Gorski wrote:
> Hi Greg,
> 
> On 18 July 2017 at 14:03, Greg Ungerer <gerg@linux-m68k.org> wrote:
>> Hi Jonas,
>>
>> On 18/07/17 20:17, Jonas Gorski wrote:
>>>
>>> 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.
>>>
>>> Fixes: facdf0ed4f59 ("m68knommu: introduce basic clk infrastructure")
>>> Cc: Greg Ungerer <gerg@linux-m68k.org>
>>
>>
>> Acked-by: Greg Ungerer <gerg@linux-m68k.org>
>>
>> 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

[toc] | [prev] | [next] | [standalone]


#1690017 — [PATCH 5/9] MIPS: AR7: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 5/9] MIPS: AR7: allow NULL clock for clk_get_rate
Message-ID<u4xLI-17C-19@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: 780019ddf02f ("MIPS: AR7: Implement clock API")
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/mips/ar7/clock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/mips/ar7/clock.c b/arch/mips/ar7/clock.c
index dda422a0f36c..0137656107a9 100644
--- a/arch/mips/ar7/clock.c
+++ b/arch/mips/ar7/clock.c
@@ -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);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690020 — [PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate
Message-ID<u4xLI-17C-37@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/mips/bcm63xx/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c
index 73626040e4d6..19577f771c1f 100644
--- a/arch/mips/bcm63xx/clk.c
+++ b/arch/mips/bcm63xx/clk.c
@@ -339,6 +339,9 @@ EXPORT_SYMBOL(clk_disable);
 
 unsigned long clk_get_rate(struct clk *clk)
 {
+	if (!clk)
+		return 0;
+
 	return clk->rate;
 }
 
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690608 — Re: [PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-07-18 22:00 +0200
SubjectRe: [PATCH 6/9] MIPS: BCM63XX: allow NULL clock for clk_get_rate
Message-ID<u4GP0-6Cx-25@gated-at.bofh.it>
In reply to#1690020
On 07/18/2017 03:17 AM, Jonas Gorski wrote:
> 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.
> 
> Fixes: e7300d04bd08 ("MIPS: BCM63xx: Add support for the Broadcom BCM63xx family of SOCs.")
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: bcm-kernel-feedback-list@broadcom.com
> Cc: James Hogan <james.hogan@imgtec.com>
> Cc: linux-mips@linux-mips.org
> Cc: linux-kernel@vger.kernel.org
> Reported-by: Mathias Kresin <dev@kresin.me>
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1690021 — [PATCH 9/9] unicore32: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 9/9] unicore32: allow NULL clock for clk_get_rate
Message-ID<u4xLJ-17C-47@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: 64909882862e ("unicore32 additional architecture files: pm related files")
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/unicore32/kernel/clock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/unicore32/kernel/clock.c b/arch/unicore32/kernel/clock.c
index b1ca775f6f6e..d867f34fdb74 100644
--- a/arch/unicore32/kernel/clock.c
+++ b/arch/unicore32/kernel/clock.c
@@ -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);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690024 — [PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate
Message-ID<u4xLJ-17C-55@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: 969003152aa9 ("blackfin: bf60x: add clock support")
Cc: Steven Miao <realmz6@gmail.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: adi-buildroot-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/blackfin/mach-bf609/clock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c
index 392a59b9a504..21a0ec18829f 100644
--- a/arch/blackfin/mach-bf609/clock.c
+++ b/arch/blackfin/mach-bf609/clock.c
@@ -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

[toc] | [prev] | [next] | [standalone]


#1690569 — Re: [PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate

FromMasahiro Yamada <yamada.masahiro@socionext.com>
Date2017-07-18 21:00 +0200
SubjectRe: [PATCH 3/9] blackfin: bf609: allow NULL clock for clk_get_rate
Message-ID<u4FSV-61V-9@gated-at.bofh.it>
In reply to#1690024
2017-07-18 19:17 GMT+09:00 Jonas Gorski <jonas.gorski@gmail.com>:
> 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.
>
> Fixes: 969003152aa9 ("blackfin: bf60x: add clock support")
> Cc: Steven Miao <realmz6@gmail.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

This Cc can be replaced with

Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Thank you.


> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: adi-buildroot-devel@lists.sourceforge.net
> Cc: linux-kernel@vger.kernel.org
> Reported-by: Mathias Kresin <dev@kresin.me>
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
> ---
>  arch/blackfin/mach-bf609/clock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c
> index 392a59b9a504..21a0ec18829f 100644
> --- a/arch/blackfin/mach-bf609/clock.c
> +++ b/arch/blackfin/mach-bf609/clock.c
> @@ -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
>



-- 
Best Regards
Masahiro Yamada

[toc] | [prev] | [next] | [standalone]


#1690026 — [PATCH 7/9] MIPS: Loongson 2F: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 7/9] MIPS: Loongson 2F: allow NULL clock for clk_get_rate
Message-ID<u4xLJ-17C-63@gated-at.bofh.it>
In reply to#1690013
Make 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.

Fixes: f8ede0f700f5 ("MIPS: Loongson 2F: Add CPU frequency scaling support")
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/mips/loongson64/lemote-2f/clock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/mips/loongson64/lemote-2f/clock.c b/arch/mips/loongson64/lemote-2f/clock.c
index a78fb657068c..8281334df9c8 100644
--- a/arch/mips/loongson64/lemote-2f/clock.c
+++ b/arch/mips/loongson64/lemote-2f/clock.c
@@ -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);
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690028 — [PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate

FromJonas Gorski <jonas.gorski@gmail.com>
Date2017-07-18 12:20 +0200
Subject[PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate
Message-ID<u4xLK-17C-77@gated-at.bofh.it>
In reply to#1690013
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.

Fixes: 1d81eedb8f6c ("[ARM] 3634/1: ep93xx: initial implementation of the clk_* API")
Cc: Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Reported-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
 arch/arm/mach-ep93xx/clock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 39ef3b613912..f0768befafe8 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -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);
 
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1690969 — Re: [PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate

FromAlexander Sverdlin <alexander.sverdlin@gmail.com>
Date2017-07-19 07:10 +0200
SubjectRe: [PATCH 1/9] ARM: ep93xx: allow NULL clock for clk_get_rate
Message-ID<u4Ppg-3SX-3@gated-at.bofh.it>
In reply to#1690028
On 18/07/17 12:17, Jonas Gorski wrote:
> 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.
> 
> Fixes: 1d81eedb8f6c ("[ARM] 3634/1: ep93xx: initial implementation of the clk_* API")
> Cc: Hartley Sweeten <hsweeten@visionengravers.com>
> Cc: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Reported-by: Mathias Kresin <dev@kresin.me>
> Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>

Acked-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>

> ---
>  arch/arm/mach-ep93xx/clock.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
> index 39ef3b613912..f0768befafe8 100644
> --- a/arch/arm/mach-ep93xx/clock.c
> +++ b/arch/arm/mach-ep93xx/clock.c
> @@ -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);

[toc] | [prev] | [next] | [standalone]


#1690211

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2017-07-18 14:10 +0200
Message-ID<u4zua-2f6-21@gated-at.bofh.it>
In reply to#1690013
Hi Jonas,

On Tue, Jul 18, 2017 at 12:17 PM, Jonas Gorski <jonas.gorski@gmail.com> wrote:
> 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.
>
> Cc: adi-buildroot-devel@lists.sourceforge.net
> Cc: bcm-kernel-feedback-list@broadcom.com
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-m68k@lists.linux-m68k.org
> Cc: linux-mips@linux-mips.org
>
> 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(-)

For the whole series:
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web