Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1969428pxb; Fri, 5 Mar 2021 04:24:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaFhp8XB9uhqbaQ+YCxutuizF1Wzg6sgrjvkzDcrgzlDdomAuUz4lRsyEDEAh7UI0eGqqV X-Received: by 2002:a17:906:4e99:: with SMTP id v25mr1995337eju.532.1614947062443; Fri, 05 Mar 2021 04:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947062; cv=none; d=google.com; s=arc-20160816; b=Xixxx1qkedm9AYvefrjmo8IPMD2n2ffz/4LwuBWwVe3m8uvgxZ+lgGCdxXnZIbspGf 83qQDOC1fzVM+ncY5+uLUMqXbbvGDNOUCTzw2guOpHPwrgnCm/35hZXnF00c7eqZ9t7Y GUHTM39vESMazLkIcS8zXWDYudAlUge0so/j7Cw+ak0fSh7eOgimIKJZZM5NszwTUhrh 82rWNnO3pqWAQYUk19vC5LUhDtPifNYuP6uYFmuZaPQfK03WYLu4Vwt8O1fZiYVvsHtB hmgDE17xqao7vNWC2n2jiVaIMTwtgx/oAGwPCQR7FKim+MQI8ZE61KiMJNgLp+Pvx++B 0rog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=bg4jxhUSkSbx+Qwbg3uwCscL20isBQGJgv5w40ZAVoE=; b=PBJRc1L/JfeqUi9nUzZBJxF5dne2FY2DiNVYKMBEHCTEy3UpkmC4dIHBY+Py97frNX rjWxeJ6J1j5QJiEf5oViJxmsqhgUA6J4HtGQ84XFerUAIdbxhkRET6WzDkxH/V1g//tq S95a2EB5lVLJbJfe0DNkOZSkV/0EJ9m7jGoH8YaMfkIE+K15Hdp/52YFEiqf49aDK7xR qtQXQIEKRLGVEtFrC1f0XhpnZZH5PVon7CzEYXxy74IPQcG1bDg4U3043aRw+dB3xHCK ti4fGC3vUjvThNQiXnzHvIRTvQQ/KLNwE05VIyrRjKfGqG7rJSvbOTLK7ZEynlRYZA03 qTbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay5si1225489ejb.692.2021.03.05.04.23.58; Fri, 05 Mar 2021 04:24:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229505AbhCEMWC (ORCPT + 99 others); Fri, 5 Mar 2021 07:22:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbhCEMVi (ORCPT ); Fri, 5 Mar 2021 07:21:38 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5811C061574 for ; Fri, 5 Mar 2021 04:21:37 -0800 (PST) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1lI9Sa-0001Ek-1H; Fri, 05 Mar 2021 13:21:36 +0100 Subject: Re: [PATCH V3] clk: imx: Fix reparenting of UARTs not associated with sdout To: Adam Ford , linux-arm-kernel@lists.infradead.org Cc: Aisheng Dong , Linus Walleij , Fabio Estevam , Stephen Boyd , Shawn Guo , Michael Turquette , aford@beaconembedded.com, linux-clk@vger.kernel.org, NXP Linux Team , Pengutronix Kernel Team , Sascha Hauer , linux-kernel@vger.kernel.org, Jerome Brunet References: <20210115182909.314756-1-aford173@gmail.com> From: Ahmad Fatoum Message-ID: Date: Fri, 5 Mar 2021 13:21:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210115182909.314756-1-aford173@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Adam, On 15.01.21 19:29, Adam Ford wrote: > { > +#ifdef CONFIG_OF > if (imx_keep_uart_clocks) { > int i; > > - imx_uart_clocks = clks; > - for (i = 0; imx_uart_clocks[i]; i++) > - clk_prepare_enable(*imx_uart_clocks[i]); > + imx_uart_clocks = kcalloc(clk_count, sizeof(struct clk *), GFP_KERNEL); > + imx_enabled_uart_clocks = 0; > + > + for (i = 0; i < clk_count; i++) { > + imx_uart_clocks[imx_enabled_uart_clocks] = of_clk_get(of_stdout, i); of_stdout may be NULL if there is no stdout-path. You should check that earlier. With this fixed, feel free to add: Tested-by: Ahmad Fatoum > + > + /* Stop if there are no more of_stdout references */ > + if (IS_ERR(imx_uart_clocks[imx_enabled_uart_clocks])) > + return; > + > + /* Only enable the clock if it's not NULL */ > + if (imx_uart_clocks[imx_enabled_uart_clocks]) > + clk_prepare_enable(imx_uart_clocks[imx_enabled_uart_clocks++]); > + } > } > +#else > + /* i.MX boards use device trees now. For build tests without CONFIG_OF, do nothing */ > + imx_enabled_uart_clocks = 0; > +#endif > } > > static int __init imx_clk_disable_uart(void) > { > - if (imx_keep_uart_clocks && imx_uart_clocks) { > + if (imx_keep_uart_clocks && imx_enabled_uart_clocks) { > int i; > > - for (i = 0; imx_uart_clocks[i]; i++) > - clk_disable_unprepare(*imx_uart_clocks[i]); > + for (i = 0; i < imx_enabled_uart_clocks; i++) { > + clk_disable_unprepare(imx_uart_clocks[i]); > + clk_put(imx_uart_clocks[i]); > + }; > + kfree(imx_uart_clocks); > } > > return 0; > diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h > index 4f04c8287286..7571603bee23 100644 > --- a/drivers/clk/imx/clk.h > +++ b/drivers/clk/imx/clk.h > @@ -11,9 +11,9 @@ extern spinlock_t imx_ccm_lock; > void imx_check_clocks(struct clk *clks[], unsigned int count); > void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count); > #ifndef MODULE > -void imx_register_uart_clocks(struct clk ** const clks[]); > +void imx_register_uart_clocks(unsigned int clk_count); > #else > -static inline void imx_register_uart_clocks(struct clk ** const clks[]) > +static inline void imx_register_uart_clocks(unsigned int clk_count) > { > } > #endif > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |