Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756788AbcDHBxP (ORCPT ); Thu, 7 Apr 2016 21:53:15 -0400 Received: from conssluserg-03.nifty.com ([210.131.2.82]:50908 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751965AbcDHBxO (ORCPT ); Thu, 7 Apr 2016 21:53:14 -0400 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com u381qwbm031711 X-Nifty-SrcIP: [209.85.161.170] MIME-Version: 1.0 In-Reply-To: <20160408003328.GA14441@codeaurora.org> References: <1459821083-28116-1-git-send-email-yamada.masahiro@socionext.com> <20160408003328.GA14441@codeaurora.org> Date: Fri, 8 Apr 2016 10:52:57 +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: Stephen Boyd Cc: linux-clk@vger.kernel.org, Ralf Baechle , Michael Turquette , linux-mips@linux-mips.org, linux-sh@vger.kernel.org, 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@lists.sourceforge.net, Russell King , linux-m68k@vger.kernel.org, linux-arm-kernel , Linux Kernel Mailing List , linux-renesas-soc@vger.kernel.org, Magnus Damm , John Crispin 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: 2361 Lines: 75 Hi Stephen, 2016-04-08 9:33 GMT+09:00 Stephen Boyd : > 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? > This makes our driver programming life easier. For example, let's see drivers/tty/serial/8250/8250_of.c The "clock-frequency" DT property takes precedence over "clocks" property. So, it is valid to probe the driver with a NULL pointer for info->clk. if (of_property_read_u32(np, "clock-frequency", &clk)) { /* Get clk rate through clk driver if present */ info->clk = devm_clk_get(&ofdev->dev, NULL); if (IS_ERR(info->clk)) { dev_warn(&ofdev->dev, "clk or clock-frequency not defined\n"); return PTR_ERR(info->clk); } ret = clk_prepare_enable(info->clk); if (ret < 0) return ret; clk = clk_get_rate(info->clk); } As a result, we need to make sure the clk pointer is valid before calling clk_disable_unprepare(). If we could support pointer checking in callees, we would be able to clean-up lots of clock consumers. -- Best Regards Masahiro Yamada