Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758228AbcDHLPV (ORCPT ); Fri, 8 Apr 2016 07:15:21 -0400 Received: from conssluserg-04.nifty.com ([210.131.2.83]:21772 "EHLO conssluserg-04.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758118AbcDHLPR (ORCPT ); Fri, 8 Apr 2016 07:15:17 -0400 X-Greylist: delayed 33722 seconds by postgrey-1.27 at vger.kernel.org; Fri, 08 Apr 2016 07:15:16 EDT DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com u38BF5wr026731 X-Nifty-SrcIP: [209.85.161.179] MIME-Version: 1.0 In-Reply-To: <20160408100600.GI1668@linux-mips.org> References: <1459821083-28116-1-git-send-email-yamada.masahiro@socionext.com> <20160408003328.GA14441@codeaurora.org> <20160408100600.GI1668@linux-mips.org> Date: Fri, 8 Apr 2016 20:15:05 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error From: Masahiro Yamada To: Ralf Baechle , Stephen Boyd Cc: linux-mips@linux-mips.org, linux-m68k@vger.kernel.org, Rich Felker , linux-sh@vger.kernel.org, Tony Lindgren , Michael Turquette , Sekhar Nori , Greg Ungerer , linux-clk@vger.kernel.org, Hans-Christian Egtvedt , Russell King , Yoshinori Sato , Kevin Hilman , Magnus Damm , Geert Uytterhoeven , Haavard Skinnemoen , Wan ZongShun , Steven Miao , adi-buildroot-devel@lists.sourceforge.net, Haojian Zhuang , Simon Horman , linux-omap@vger.kernel.org, linux-arm-kernel , John Crispin , Paul Walmsley , Eric Miao , Ryan Mallon , Linux Kernel Mailing List , linux-renesas-soc@vger.kernel.org, Hartley Sweeten Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2612 Lines: 97 2016-04-08 19:06 GMT+09:00 Ralf Baechle : > 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 >> > Acked-by: Greg Ungerer >> > Acked-by: Wan Zongshun >> > --- >> > >> > 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