From patchwork Sun Jan 3 06:47:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 7942941 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DFDF69F32E for ; Sun, 3 Jan 2016 06:53:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E683220357 for ; Sun, 3 Jan 2016 06:53:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 294BD20351 for ; Sun, 3 Jan 2016 06:53:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aFcUx-0003Hd-DV; Sun, 03 Jan 2016 06:50:39 +0000 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aFcUt-0003F9-EX for linux-arm-kernel@lists.infradead.org; Sun, 03 Jan 2016 06:50:36 +0000 Received: by mail-pf0-x22d.google.com with SMTP id 65so140738157pff.3 for ; Sat, 02 Jan 2016 22:50:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=content-type:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=qCvY8YSfihI14A3kIQDZGCeo0GIG/MvpZ4r+/pZwd1M=; b=ggiK8t8i1Nsxa7KbF5wKDUMrTwKUZW9wYOSn3kwe83UEmss/0DBHG4uB4MWDc8NTmG n66PLLuxCv6MZzw41YrGkoPbNrZcKXxGMgLtK7mV0ZqaZItX7O1Q5e5hZZc1M7G83Fsh /nz8LAACOO7Woj8+Kte8j+6RQppK2llHdkdTTR48Ecn0mU7ecGlsuuSUoabK8WUSvfxI IZz9/mVawIxmP/nApcTQJzu3fKtN1SiqDDpueXV/4bdelWfbx0TgdSP+luryTRCU8FpV zNIJ2fKAZWmAyVx1bW+NKncLRghImFKiox9W7WfhE5dxv2WGeSt9c4Mq2PaPjGZCd/nG fbbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version :content-transfer-encoding:to:from:in-reply-to:cc:references :message-id:user-agent:subject:date; bh=qCvY8YSfihI14A3kIQDZGCeo0GIG/MvpZ4r+/pZwd1M=; b=Ob71eCXy2k/5eM1FA+DD+6XiYApqAFeDQeygK9lyihyKTEjzgK0Wq5nNpQr2Z2wVvD viy5pph3ArIUssJCn0OMIdbnButIl0KsVR9IdFjedlNNVWKrFJn368PR30LlnjADdS4I 19moOJ9ma8C0CNbinlTcIe0fD8TXQpi5tqX2FuZ/W0wNAX/BCBa7sCAmcyae3baRJsv8 JENaa8pu+mx1CQEnUDX3uKFng9w7ysx3cf17gABiHuscIqjTx7CxQ8iVh6rc27q1AvwN Mra3rWwl24YUQSg6/szCkUp+ffyIfA2oPYGw1PM1wf72ydUhtxKJkfuzHAOJwbg0wuNf wszg== X-Gm-Message-State: ALoCoQn7/PsXfxZjVO/acGKG8d7TvQgyrmrNSgCPVdtn6ABV3Vz/glM56yrl55DrzzyZgXCuURIOTHTdMPXQSP9xoM6SJMpE9A== X-Received: by 10.98.70.2 with SMTP id t2mr116162451pfa.119.1451803814118; Sat, 02 Jan 2016 22:50:14 -0800 (PST) Received: from localhost (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id 70sm62636235pfa.3.2016.01.02.22.50.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jan 2016 22:50:13 -0800 (PST) MIME-Version: 1.0 To: Russell King , "Stephen Boyd" From: Michael Turquette In-Reply-To: References: Message-ID: <20160103064749.15239.59588@quark.deferred.io> User-Agent: alot/0.3.6 Subject: Re: [PATCH] clk: fix clk-gpio.c with optional clock= DT property Date: Sat, 02 Jan 2016 22:47:49 -0800 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160102_225035_585361_81C45DE0 X-CRM114-Status: GOOD ( 18.67 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Russell, Quoting Russell King (2016-01-02 02:01:34) > When the clock DT property is not given, of_clk_get_parent_count() > returns -ENOENT, which then tries to allocate -2 x 4 bytes of memory, > which of course fails, causing the whole driver to fail to create > the clock. > > This causes the SolidRun platforms to fail probing the SDHCI1 interface > which is connected to the WiFi. > > Fix this by detecting errno codes, skipping the allocation, and fixing > of_clk_gpio_gate_delayed_register_get() to handle a NULL parent_names > array. Thanks for the fix. Applied to clk-next manually. > > Fixes: 80eeb1f0f757 ("clk: add gpio controlled clock multiplexer") > Signed-off-by: Russell King > --- > This goes all the way back to 80eeb1f0f757 ("clk: add gpio controlled > clock multiplexer") introduced in June in v4.3-rc2 - which raises the > question why _development_ work in clk is being merged outside of the > merge window. That patch was merged into the clk tree in June 2015, based on 4.2-rc1. v4.2 was release on Sunday, August 30, 2015. My pull request to Linus containing this patch was sent on Monday, August 31, 2015. Thread archived here: http://lkml.kernel.org/r/<20150831192125.11508.92473@quantum> Looks like it was merged in 4.3-rc1 as well: $ git log v4.3-rc1..clk-for-linus-4.3 $ > > A rewrite of this patch will be necessary to apply to v4.3 kernels. > > This applies on top of v4.4-rc6. Alternatively we can send f66541ba02d5 "clk: gpio: Get parent clk names in of_gpio_clk_setup()" along with your fix. Below is the modified version of your patch. Regards, Mike commit 60f7e5a537f367d3be7cff2bce13c91c10bdf451 Author: Russell King Date: Sat Jan 2 10:01:34 2016 +0000 clk: fix clk-gpio.c with optional clock= DT property When the clock DT property is not given, of_clk_get_parent_count() returns -ENOENT, which then tries to allocate -2 x 4 bytes of memory, which of course fails, causing the whole driver to fail to create the clock. This causes the SolidRun platforms to fail probing the SDHCI1 interface which is connected to the WiFi. Fix this by detecting errno codes, skipping the allocation, and fixing of_clk_gpio_gate_delayed_register_get() to handle a NULL parent_names array. Fixes: 80eeb1f0f757 ("clk: add gpio controlled clock multiplexer") Signed-off-by: Russell King Signed-off-by: Michael Turquette diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c index 1767b9e..19fed65 100644 --- a/drivers/clk/clk-gpio.c +++ b/drivers/clk/clk-gpio.c @@ -264,8 +264,8 @@ static struct clk *of_clk_gpio_gate_delayed_register_get(const char *name, const char * const *parent_names, u8 num_parents, unsigned gpio, bool active_low) { - return clk_register_gpio_gate(NULL, name, parent_names[0], - gpio, active_low, 0); + return clk_register_gpio_gate(NULL, name, parent_names ? + parent_names[0] : NULL, gpio, active_low, 0); } static struct clk *of_clk_gpio_mux_delayed_register_get(const char *name, @@ -295,15 +295,19 @@ static void __init of_gpio_clk_setup(struct device_node *node, if (!data) return; - parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL); - if (!parent_names) { - kfree(data); - return; + if (num_parents) { + parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL); + if (!parent_names) { + kfree(data); + return; + } + + for (i = 0; i < num_parents; i++) + parent_names[i] = of_clk_get_parent_name(node, i); + } else { + parent_names = NULL; } - for (i = 0; i < num_parents; i++) - parent_names[i] = of_clk_get_parent_name(node, i); - data->num_parents = num_parents; data->parent_names = parent_names; data->node = node;