Received: by 10.192.165.148 with SMTP id m20csp110171imm; Tue, 1 May 2018 18:45:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHW2cz2QV8/fEQzFESETGeTI1GiPJrdpa7ND75aszDnYRufP5Jwrv6ndp5BUpDRFsC0qT+ X-Received: by 2002:a63:62c6:: with SMTP id w189-v6mr14849094pgb.263.1525225517933; Tue, 01 May 2018 18:45:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525225517; cv=none; d=google.com; s=arc-20160816; b=yEm+dgoSLRCnP4zJjqjpK1VG7ILSZiieb3S/RoB1Erqx3tWc1+vC8EY7LzWX2N/SKq l2XkfOswTliGzFpYw7hOan3J00nFbEgsL+S0QT8OPHBM0CXAJySkPCD6Gwze9E+ENLVy K6viwA7664Xy5O0KyuSGTPyrDpX8oQzwBulKCvQs1jqsPCtPNyVDgN6Ro3pXIONBJY4J 8LP/ToBzBrpB6NODnK5b+HDX6JB92VGIebc78HNolp81llWpx6Puy2FPvZTUS8zoEa8H 1KMMrrQHEhMSuo2ELOd/Z7JWKNR0U+idHow3jG3pfYtLVWR4vfLpMZBZrI7DP/u/7maO TuFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Z5siP1RRiqYJ3vPAat1fieJ+9lmY0/CogFFHR9UAMrs=; b=ZXEGAjJYwhzKPPpuaKuBzt1lJ+Eg+X3b1/SHYFVLGvueo5eISpd8GlmvyMrU93DCvR F0bZa0Xk4Z6/xppRbi4zTXJR7H4oPOvN2JWFtLySSpKrcOJofr61QyNmdfWRm0xJWO6w G5+7uN+i5Tqw8E1WzR6WpdRn4YteOQRf/eSOcw/yhhXf0Ax/wmU8PR8P6BOVCnV2bdwS Q4beH41gThplBcBTuBtnxv4W2vIzVlMN1zHcVk4yTG8CwQqLwpBM3dEQcA5LmkySbB8a 4K7qh2vif4YOpx9qlO9vs4tooheyZ+WTj4XamjKLKiND9H7AEa1i7Cx4vtWKrZndqZSB BROw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=PX/fE+tQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7si9578035pfh.3.2018.05.01.18.45.02; Tue, 01 May 2018 18:45:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=PX/fE+tQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751055AbeEBBoz (ORCPT + 99 others); Tue, 1 May 2018 21:44:55 -0400 Received: from vern.gendns.com ([206.190.152.46]:52521 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750743AbeEBBox (ORCPT ); Tue, 1 May 2018 21:44:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z5siP1RRiqYJ3vPAat1fieJ+9lmY0/CogFFHR9UAMrs=; b=PX/fE+tQjyp09TU7cn87/DJrDa As4kzJ005O7ulsVoSJqC2ome8Rcip1Ab6FzlBmTUJss2F1gN3BfhimT4hhKh9KIaOU/g5gHbxcN7x o7IPzh+DUCu2xtPXCA3W7K/djEsG4klfOHb8ydI6OwNPYydFYsM5+Mpw4tuWo2lXzzOCz1MgjLStT enUenr0ANd5edeRvsOewHPO1epGD495mknT0w0ojQXdOvxXGqNJtvsfQlseiQtkusezfF8OCLqvUa YlMKBC7sFgAhWdRJ7IPvzcB7dNas8hl9TwbeSQ3fOjybO8SzuxTQKbR2fY2JG0wrYvo+tfDkDWj28 qrMmn8Qg==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:46298 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1fDgp7-002AYC-GO; Tue, 01 May 2018 21:44:49 -0400 Subject: Re: [PATCH v9 01/27] clk: davinci: pll: allow dev == NULL To: Sekhar Nori , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , Kevin Hilman , Bartosz Golaszewski , Adam Ford , linux-kernel@vger.kernel.org References: <20180427001745.4116-1-david@lechnology.com> <20180427001745.4116-2-david@lechnology.com> <7f968fd3-eb0e-37ba-9f2d-2b948640ef73@ti.com> From: David Lechner Message-ID: <5177c1e3-9004-0d6e-6707-caf3c7efc884@lechnology.com> Date: Tue, 1 May 2018 20:44:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <7f968fd3-eb0e-37ba-9f2d-2b948640ef73@ti.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/01/2018 08:27 AM, Sekhar Nori wrote: > On Friday 27 April 2018 05:47 AM, David Lechner wrote: >> This modifies the TI DaVinci PLL clock driver to allow for the case >> when dev == NULL. On some (most) SoCs that use this driver, the PLL >> clock needs to be registered during early boot because it is used >> for clocksource/clockevent and there will be no platform device available. >> >> Signed-off-by: David Lechner > >> diff --git a/drivers/clk/davinci/pll.c b/drivers/clk/davinci/pll.c >> index 23a24c944f1d..7c4d808b8fdb 100644 >> --- a/drivers/clk/davinci/pll.c >> +++ b/drivers/clk/davinci/pll.c >> @@ -111,6 +111,31 @@ struct davinci_pll_clk { >> #define to_davinci_pll_clk(_hw) \ >> container_of((_hw), struct davinci_pll_clk, hw) >> >> +static inline void *_devm_kzalloc(struct device *dev, size_t size, gfp_t flags) >> +{ >> + if (dev) >> + return devm_kzalloc(dev, size, flags); >> + >> + return kzalloc(size, flags); > > I would shift to using kzalloc() only. The utility of devm_kzalloc() is > gone if you cannot always rely on it since you have to handle the free > for the other case. Same thing for other devres APIs below. > I omitted the usual unwinding on failure since if a non-platform-device clock fails to init, then Linux won't boot anyway. I left the devm stuff in there since there is one case where this driver is still used as a platform device, thinking that there could be an EPROBE_DEFER. However I think all uses of these inline functions are after the last possible EPROBE_DEFER, so doing as you suggest is probably just fine. >> +} >> + >> +static inline void *_devm_kmalloc_array(struct device *dev, size_t n, >> + size_t size, gfp_t flags) >> +{ >> + if (dev) >> + return devm_kmalloc_array(dev, n, size, flags); >> + >> + return kmalloc_array(n, size, flags); >> +} >> + >> +static inline struct clk *_devm_clk_register(struct device *dev, struct clk_hw *hw) >> +{ >> + if (dev) >> + return devm_clk_register(dev, hw); >> + >> + return clk_register(NULL, hw); >> +} >> + > > >> diff --git a/drivers/clk/davinci/pll.h b/drivers/clk/davinci/pll.h >> index b1b6fb23f972..92a0978a7d29 100644 >> --- a/drivers/clk/davinci/pll.h >> +++ b/drivers/clk/davinci/pll.h >> @@ -11,6 +11,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #define PLL_HAS_CLKMODE BIT(0) /* PLL has PLLCTL[CLKMODE] */ >> @@ -94,7 +95,8 @@ struct davinci_pll_obsclk_info { >> struct clk *davinci_pll_clk_register(struct device *dev, >> const struct davinci_pll_clk_info *info, >> const char *parent_name, >> - void __iomem *base); >> + void __iomem *base, >> + struct regmap *cfgchip); >> struct clk *davinci_pll_auxclk_register(struct device *dev, >> const char *name, >> void __iomem *base); >> @@ -110,32 +112,33 @@ davinci_pll_sysclk_register(struct device *dev, >> const struct davinci_pll_sysclk_info *info, >> void __iomem *base); >> >> -int of_davinci_pll_init(struct device *dev, >> +int of_davinci_pll_init(struct device *dev, struct device_node *node, >> const struct davinci_pll_clk_info *info, >> const struct davinci_pll_obsclk_info *obsclk_info, >> const struct davinci_pll_sysclk_info **div_info, >> u8 max_sysclk_id, >> - void __iomem *base); >> + void __iomem *base, >> + struct regmap *cfgchip); >> >> /* Platform-specific callbacks */ >> >> -int da830_pll_init(struct device *dev, void __iomem *base); >> +int da830_pll_init(struct device *dev, void __iomem *base, struct regmap *cfgchip); >> >> -int da850_pll0_init(struct device *dev, void __iomem *base); >> -int da850_pll1_init(struct device *dev, void __iomem *base); >> -int of_da850_pll0_init(struct device *dev, void __iomem *base); >> -int of_da850_pll1_init(struct device *dev, void __iomem *base); >> +int da850_pll0_init(struct device *dev, void __iomem *base, struct regmap *cfgchip); > > Having this declared both here and in include/linux/clk/davinci.h is > strange. Can we include that file directly where its needed? > Sure thing. There are a number of duplicates that can be eliminated. >> diff --git a/include/linux/clk/davinci.h b/include/linux/clk/davinci.h >> new file mode 100644 >> index 000000000000..1298cca509ac >> --- /dev/null >> +++ b/include/linux/clk/davinci.h >> @@ -0,0 +1,24 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Clock driver for TI Davinci PSC controllers > > PSC/PLL controllers. > > Thanks, > Sekhar >