Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2310984imm; Thu, 18 Oct 2018 12:26:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV62FKq+yzmAxE9bVvjhZID9Uw32uYmvUr/4Xn6SLk/jaASkxCfDsdDHaHCouQbpyAS+GYERJ X-Received: by 2002:a63:4045:: with SMTP id n66-v6mr6940083pga.244.1539890810566; Thu, 18 Oct 2018 12:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539890810; cv=none; d=google.com; s=arc-20160816; b=sgmQGVQ4yw5q5Cb+wMO2brjHHMEb/F1PVL5ZynvnlY4yByRo6/rUI1OkGVJx7wHIIY hWcJGj2tmaN5AhorqSLp6TG1UYQnlTPUtrQuBEDL11fydaoN9Ixk2jZW+MVfI6vabXTa J6yOFjbgqz3ZZqK+fcCZXHx3nHVWePiJ57/QXlNa40sAROJUlrw88DffXOT4QyyHMsJN LQAccFp01HK4BQNRswxc3s0RRINGfzW8sY8LLlRR2Qnhmtq3m9XSZPBgbY8HzClmDNyF pI4k7FAFFneB1Z6DZTIVj/iy9kLdVeTWKRiEjbQDMIH2xg6z3Gncx1GrVM0+E4qKCoOx ssFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uGVVv/8U1BFcLOnsmpZ2ARtZfTw0blfWt/mMfmj2k0Q=; b=VyFs1w34OKUYD+sKsUXu5MqMrqWeCs6tl8PnNUhvrx6sj/2UXb1Napp5jRpOivBtFa hgZxotrJ5X2tUKReBJ49Wz2HAmGlHabDP+f06HP3Z3j5+uG3IPs6J7zIqFGnxXgaU5pS triehm4RpmMmm6/5ztd1RFdw7QiDKBgZQqS+yhzpGOdTmylfZ9RQHCaQirEPrLUGZRaP La5jWM+kxG0CiptOuzooZPQ3yuxRed6E8dGWXXe8t9cSY7GYAlyJ9JaFSrLtaljPcwWh flIoVCyD0o2ehfZy9zIEqLVJUZI1CojoMDR0D9Yubc6SnnbizV4jXqcDL8G0GXZg+qC2 Misw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wqX4Wh3h; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w18-v6si20849975ply.66.2018.10.18.12.26.34; Thu, 18 Oct 2018 12:26:50 -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=pass header.i=@kernel.org header.s=default header.b=wqX4Wh3h; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbeJSDYE (ORCPT + 99 others); Thu, 18 Oct 2018 23:24:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:46480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbeJSDYE (ORCPT ); Thu, 18 Oct 2018 23:24:04 -0400 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3EA6D21476; Thu, 18 Oct 2018 19:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539890496; bh=H+mBwA2ReuoBbN11cOj7/ExoCDTpjlqOL2a8gqdrhx4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=wqX4Wh3hxAJebP3g5eCNizliUrLZQLE2rtaXzH1Yu3YDNABfOTeWLyMO2phSdHtMT RYUfRtHNjB6QNDm5wh4tEyhejJkEqMjiV16Aa989W26vGZcAKKxc2BVh0w/x/nfCSV SDQnWeA1T4IFmak4pvkD1IpS3VA62fylPZE3rCJ4= Received: by mail-ed1-f51.google.com with SMTP id y19-v6so29296271edd.2; Thu, 18 Oct 2018 12:21:36 -0700 (PDT) X-Gm-Message-State: ABuFfoir5yW+z0ObHzGEQI7xCvsVGuP7eNQkNQFo61fQAhYCUhsf7NWe qhQxSGe2fjJ9ZKQ/O7AW6/9XxbzQusvnfOPnqkE= X-Received: by 2002:a50:92fd:: with SMTP id l58-v6mr4363946eda.200.1539890494684; Thu, 18 Oct 2018 12:21:34 -0700 (PDT) MIME-Version: 1.0 References: <1467735814-23518-1-git-send-email-ricardo.ribalda@gmail.com> <1467735814-23518-11-git-send-email-ricardo.ribalda@gmail.com> In-Reply-To: <1467735814-23518-11-git-send-email-ricardo.ribalda@gmail.com> From: Alan Tull Date: Thu, 18 Oct 2018 14:20:58 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 8/8] clk: fixed-rate: Convert into a module platform driver To: Ricardo Ribalda Delgado Cc: mturquette@baylibre.com, sboyd@codeaurora.org, Sascha Hauer , linux-clk@vger.kernel.org, linux-kernel , Frank Rowand Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 5, 2016 at 11:45 AM Ricardo Ribalda Delgado wrote: I've stumbled across a of_node_get/put imbalance that happens when the fixed rate clock is added and deleted using device tree. The cause is that this driver calls of_clk_add_provider() when probed, but doesn't call of_clk_del_provider() when removed. It looks like a lot of clock drivers share that issue: $ cd drivers/clk/ $ git grep -l of_clk_add_provider * | xargs grep -L of_clk_del_provider | wc -l 131 It should be a one line fix, but for many files. I'm not a clock subsystem expert, so please let me know whether I'm missing something here. Thanks, Alan > > Adds support for fixed-rate clock providers which have not been > enabled via of_clk_init(). > > This is required by Device trees overlays that introduce clocks > providers. > > Signed-off-by: Ricardo Ribalda Delgado > --- > drivers/clk/clk-fixed-rate.c | 69 +++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 65 insertions(+), 4 deletions(-) > > diff --git a/drivers/clk/clk-fixed-rate.c b/drivers/clk/clk-fixed-rate.c > index 2edb39342a02..e64ba2315880 100644 > --- a/drivers/clk/clk-fixed-rate.c > +++ b/drivers/clk/clk-fixed-rate.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > /* > * DOC: basic fixed-rate clock that cannot gate > @@ -160,15 +161,16 @@ EXPORT_SYMBOL_GPL(clk_hw_unregister_fixed_rate); > /** > * of_fixed_clk_setup() - Setup function for simple fixed rate clock > */ > -void of_fixed_clk_setup(struct device_node *node) > +struct clk *_of_fixed_clk_setup(struct device_node *node) > { > struct clk *clk; > const char *clk_name = node->name; > u32 rate; > u32 accuracy = 0; > + int ret; > > if (of_property_read_u32(node, "clock-frequency", &rate)) > - return; > + return ERR_PTR(-EIO); > > of_property_read_u32(node, "clock-accuracy", &accuracy); > > @@ -176,9 +178,68 @@ void of_fixed_clk_setup(struct device_node *node) > > clk = clk_register_fixed_rate_with_accuracy(NULL, clk_name, NULL, > 0, rate, accuracy); > - if (!IS_ERR(clk)) > - of_clk_add_provider(node, of_clk_src_simple_get, clk); > + if (IS_ERR(clk)) > + return clk; > + > + ret = of_clk_add_provider(node, of_clk_src_simple_get, clk); > + if (ret) { > + clk_unregister(clk); > + return ERR_PTR(ret); > + } > + > + return clk; > +} > + > +void of_fixed_clk_setup(struct device_node *node) > +{ > + _of_fixed_clk_setup(node); > } > EXPORT_SYMBOL_GPL(of_fixed_clk_setup); > CLK_OF_DECLARE(fixed_clk, "fixed-clock", of_fixed_clk_setup); > + > +static int of_fixed_clk_remove(struct platform_device *pdev) > +{ > + struct clk *clk = platform_get_drvdata(pdev); > + > + if (clk) > + clk_unregister_fixed_rate(clk); > + > + return 0; > +} > + > +static int of_fixed_clk_probe(struct platform_device *pdev) > +{ > + struct clk *clk; > + > + /* > + * This function is not executed when of_fixed_clk_setup > + * succeeded. > + */ > + > + clk = _of_fixed_clk_setup(pdev->dev.of_node); > + > + if (IS_ERR(clk)) > + return PTR_ERR(clk); > + > + platform_set_drvdata(pdev, clk); > + > + return 0; > +} > + > +static const struct of_device_id of_fixed_clk_ids[] = { > + { .compatible = "fixed-clock" }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, of_fixed_clk_ids); > + > +static struct platform_driver of_fixed_clk_driver = { > + .driver = { > + .name = "of_fixed_clk", > + .of_match_table = of_fixed_clk_ids, > + }, > + .probe = of_fixed_clk_probe, > + .remove = of_fixed_clk_remove, > +}; > + > +builtin_platform_driver(of_fixed_clk_driver); > #endif > -- > 2.8.1 >