linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error
       [not found] ` <20160408003328.GA14441@codeaurora.org>
@ 2016-04-08 10:06   ` Ralf Baechle
  2016-04-08 11:15     ` Masahiro Yamada
  2016-04-14  0:40     ` Stephen Boyd
  0 siblings, 2 replies; 3+ messages in thread
From: Ralf Baechle @ 2016-04-08 10:06 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Masahiro Yamada, linux-clk, Michael Turquette, linux-mips,
	linux-sh, Haojian Zhuang, Eric Miao, Hartley Sweeten,
	Greg Ungerer, Ryan Mallon, Geert Uytterhoeven, Steven Miao,
	Simon Horman, Wan ZongShun, Rich Felker, Yoshinori Sato,
	adi-buildroot-devel, Russell King, linux-m68k, linux-arm-kernel,
	linux-kernel

On Thu, Apr 07, 2016 at 05:33:28PM -0700, Stephen Boyd wrote:

> On 04/05, Masahiro Yamada wrote:
> > The clk_disable() in the common clock framework (drivers/clk/clk.c)
> > returns immediately if a given clk is NULL or an error pointer.  It
> > allows clock consumers to call clk_disable() without IS_ERR_OR_NULL
> > checking if drivers are only used with the common clock framework.
> > 
> > Unfortunately, NULL/error checking is missing from some of non-common
> > clk_disable() implementations.  This prevents us from completely
> > dropping NULL/error checking from callers.  Let's make it tree-wide
> > consistent by adding IS_ERR_OR_NULL(clk) to all callees.
> > 
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Acked-by: Greg Ungerer <gerg@uclinux.org>
> > Acked-by: Wan Zongshun <mcuos.com@gmail.com>
> > ---
> > 
> > Stephen,
> > 
> > This patch has been unapplied for a long time.
> > 
> > Please let me know if there is something wrong with this patch.
> > 
> 
> I'm mostly confused why we wouldn't want to encourage people to
> call clk_disable or unprepare on a clk that's an error pointer.
> Typically an error pointer should be dealt with, instead of
> silently ignored, so why wasn't it dealt with by passing it up
> the probe() path?

While your argument makes perfect sense, Many clk_disable implementations
are already doing similar checks, for example:

arch/arm/mach-davinci/clock.c:

void clk_disable(struct clk *clk)
{
	unsigned long flags;

	if (clk == NULL || IS_ERR(clk))
		return;
[...]

arch/arm/mach-omap1/clock.c

void clk_disable(struct clk *clk)
{
        unsigned long flags;

        if (clk == NULL || IS_ERR(clk))
                return;
[...]

arch/avr32/mach-at32ap/clock.c

void clk_disable(struct clk *clk)
{
        unsigned long flags;

        if (IS_ERR_OR_NULL(clk))
                return;
[...]

arch/mips/lantiq/clk.c:

static inline int clk_good(struct clk *clk)
{
	return clk && !IS_ERR(clk);
}

[...]

void clk_disable(struct clk *clk)
{
	if (unlikely(!clk_good(clk)))
		return;

	if (clk->disable)
[...]

So should we go and weed out these checks?

  Ralf

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

* Re: [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error
  2016-04-08 10:06   ` [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error Ralf Baechle
@ 2016-04-08 11:15     ` Masahiro Yamada
  2016-04-14  0:40     ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2016-04-08 11:15 UTC (permalink / raw)
  To: Ralf Baechle, Stephen Boyd
  Cc: linux-mips, linux-m68k, Rich Felker, linux-sh, Tony Lindgren,
	Michael Turquette, Sekhar Nori, Greg Ungerer, linux-clk,
	Hans-Christian Egtvedt, Russell King, Yoshinori Sato,
	Kevin Hilman, Magnus Damm, Geert Uytterhoeven, Haavard Skinnemoen,
	Wan ZongShun, Steven Miao, adi-buildroot-devel, Haojian Zhuang,
	Simon Horman, linux-omap, linux-arm-kernel, John Crispin

2016-04-08 19:06 GMT+09:00 Ralf Baechle <ralf@linux-mips.org>:
> On Thu, Apr 07, 2016 at 05:33:28PM -0700, Stephen Boyd wrote:
>
>> On 04/05, Masahiro Yamada wrote:
>> > The clk_disable() in the common clock framework (drivers/clk/clk.c)
>> > returns immediately if a given clk is NULL or an error pointer.  It
>> > allows clock consumers to call clk_disable() without IS_ERR_OR_NULL
>> > checking if drivers are only used with the common clock framework.
>> >
>> > Unfortunately, NULL/error checking is missing from some of non-common
>> > clk_disable() implementations.  This prevents us from completely
>> > dropping NULL/error checking from callers.  Let's make it tree-wide
>> > consistent by adding IS_ERR_OR_NULL(clk) to all callees.
>> >
>> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> > Acked-by: Greg Ungerer <gerg@uclinux.org>
>> > Acked-by: Wan Zongshun <mcuos.com@gmail.com>
>> > ---
>> >
>> > Stephen,
>> >
>> > This patch has been unapplied for a long time.
>> >
>> > Please let me know if there is something wrong with this patch.
>> >
>>
>> I'm mostly confused why we wouldn't want to encourage people to
>> call clk_disable or unprepare on a clk that's an error pointer.
>> Typically an error pointer should be dealt with, instead of
>> silently ignored, so why wasn't it dealt with by passing it up
>> the probe() path?
>
> While your argument makes perfect sense, Many clk_disable implementations
> are already doing similar checks, for example:
>
> arch/arm/mach-davinci/clock.c:
>
> void clk_disable(struct clk *clk)
> {
>         unsigned long flags;
>
>         if (clk == NULL || IS_ERR(clk))
>                 return;
> [...]
>
> arch/arm/mach-omap1/clock.c
>
> void clk_disable(struct clk *clk)
> {
>         unsigned long flags;
>
>         if (clk == NULL || IS_ERR(clk))
>                 return;
> [...]
>
> arch/avr32/mach-at32ap/clock.c
>
> void clk_disable(struct clk *clk)
> {
>         unsigned long flags;
>
>         if (IS_ERR_OR_NULL(clk))
>                 return;
> [...]
>
> arch/mips/lantiq/clk.c:
>
> static inline int clk_good(struct clk *clk)
> {
>         return clk && !IS_ERR(clk);
> }
>
> [...]
>
> void clk_disable(struct clk *clk)
> {
>         if (unlikely(!clk_good(clk)))
>                 return;
>
>         if (clk->disable)
> [...]
>
> So should we go and weed out these checks?
>
>   Ralf


Please help me understand your thought clearly.

[1] Should calling clk_unprepare/disable() with a NULL pointer be allowed?

[2] Should calling clk_unprepare/disable() with an error pointer be allowed?


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error
  2016-04-08 10:06   ` [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error Ralf Baechle
  2016-04-08 11:15     ` Masahiro Yamada
@ 2016-04-14  0:40     ` Stephen Boyd
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2016-04-14  0:40 UTC (permalink / raw)
  To: Ralf Baechle
  Cc: Masahiro Yamada, linux-clk, Michael Turquette, linux-mips,
	linux-sh, Haojian Zhuang, Eric Miao, Hartley Sweeten,
	Greg Ungerer, Ryan Mallon, Geert Uytterhoeven, Steven Miao,
	Simon Horman, Wan ZongShun, Rich Felker, Yoshinori Sato,
	adi-buildroot-devel, Russell King, linux-m68k, linux-arm-kernel,
	linux-kernel, linux-renesas-soc, Magnus Damm, John Crispin

On 04/08, Ralf Baechle wrote:
> 
> While your argument makes perfect sense, Many clk_disable implementations
> are already doing similar checks, for example:
> 
> arch/arm/mach-davinci/clock.c:
> 
[...]
> 
> So should we go and weed out these checks?

Yes, it would be nice to at least make the differing
implementations of the clk API consistent. Of course, we should
really put our efforts towards getting rid of the non-CCF
implementations instead so that there's less confusion overall.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2016-04-14  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1459821083-28116-1-git-send-email-yamada.masahiro@socionext.com>
     [not found] ` <20160408003328.GA14441@codeaurora.org>
2016-04-08 10:06   ` [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error Ralf Baechle
2016-04-08 11:15     ` Masahiro Yamada
2016-04-14  0:40     ` 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).