Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp684854yba; Fri, 12 Apr 2019 11:32:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5N/oZMSyHvSdkv/2ydonDC87Uv0ThIcK2i0fzEXbMnfdOiqpMXrNlpRHfUmrfSaZTqcgk X-Received: by 2002:a17:902:9341:: with SMTP id g1mr21232268plp.81.1555093975394; Fri, 12 Apr 2019 11:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555093975; cv=none; d=google.com; s=arc-20160816; b=qaEnEm0W3+/TpW8S3V4yiqKnWUEDhG5/AdkIzmFf3L86TPYmQ/K2ZsyKEC3B9pr49w /5mUCBoexLW4kt/0Y4I7xd4yUxscrgY5oGgiWZcyxW30lT+csm6iOz45jtbZqdGf+S3W LSD5D6x5co+NZJXOX3v/pN5dLBOfuhDh0WQ0LK6yrkOBkHJ388gYuSCW/ad7IRYcFhu7 HyElG8I5UI0RokxROiyFkGY4evdIkOQtXQULZEq0rT9aqTC+1LwykKqK0wcccR1gWu12 syO+PO3PW3OKcLC+1/Yfjfga33y+2mIAaZZSwC8647Dc6OTq59BtSDui5KPoCtA+UJEY bC4w== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SANO8On3w0RYwd6lEEmStU0C5cpeLBcdwvYaokn/u/U=; b=wu9CHOx27o8Lblknr7RPeExE3g5aIHZ9+wnOiVc3r8oJzTolBQNrjPWwHv2i4E9jtb aE7PfCl2cLO6/+l1JbWE3NB8yNuyC3oBgT92t37VZGMxi5FzOdOtW0SG+Hwmw0PH9Ssj pp0t9cbt8jEIyGYFmDFWuQhBkk0vCddVdFjMq0GfxaWMDpj9AbOwe1TDxDgw2zrEpvm9 zgV72CWju6br6kMwrjwCuw85TxDC94MDoLYtZyXaB+3AW1do9uK9nWEfRnUFV2oZRisD tVxvGhJgAD/yVg3WmB4CieqZoDkH5liFG8xxdgXdoRODMqbUgIBC0ZgWgO4TqAr/qF2W Ytlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I5LVaitt; 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 2si15553281pld.334.2019.04.12.11.32.39; Fri, 12 Apr 2019 11:32:55 -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=I5LVaitt; 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 S1727101AbfDLSb7 (ORCPT + 99 others); Fri, 12 Apr 2019 14:31:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:50396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbfDLSb4 (ORCPT ); Fri, 12 Apr 2019 14:31:56 -0400 Received: from mail.kernel.org (unknown [104.132.0.74]) (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 476EA218FD; Fri, 12 Apr 2019 18:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555093915; bh=HcIechYl/c6FVy1DBpjkLY6E2a4oNKzK9h0x6CXvb6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5LVaitt0gaP9Kgq/jQq6EjSMNPxDolCIh2FYdQEkRl1dmXI1sr03GhxZ7hIDuK3a 63fD2KVZFKqGwVYOx9PUoTcSUR/nAUBhrMegibf8LE1MkFA+ml/bkDu3UiLHMjk1Vy N6JbNZ5Di9f2ErAysLQx11oQKlNJazUKrD2p9EZU= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Miquel Raynal , Jerome Brunet , Russell King , Jeffrey Hugo , Chen-Yu Tsai Subject: [PATCH v4 9/9] clk: fixed-factor: Let clk framework find parent Date: Fri, 12 Apr 2019 11:31:50 -0700 Message-Id: <20190412183150.102131-10-sboyd@kernel.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190412183150.102131-1-sboyd@kernel.org> References: <20190412183150.102131-1-sboyd@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert this driver to a more modern way of specifying parents now that we have a way to specify clk parents by DT index. This lets us nicely avoid a problem where a parent clk name isn't know because the parent clk hasn't been registered yet. Cc: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette Cc: Jeffrey Hugo Cc: Chen-Yu Tsai Signed-off-by: Stephen Boyd --- drivers/clk/clk-fixed-factor.c | 53 +++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c index 241b3f8c61a9..67cc7e515e42 100644 --- a/drivers/clk/clk-fixed-factor.c +++ b/drivers/clk/clk-fixed-factor.c @@ -64,12 +64,14 @@ const struct clk_ops clk_fixed_factor_ops = { }; EXPORT_SYMBOL_GPL(clk_fixed_factor_ops); -struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, - const char *name, const char *parent_name, unsigned long flags, - unsigned int mult, unsigned int div) +static struct clk_hw * +__clk_hw_register_fixed_factor(struct device *dev, struct device_node *np, + const char *name, const char *parent_name, int index, + unsigned long flags, unsigned int mult, unsigned int div) { struct clk_fixed_factor *fix; struct clk_init_data init; + struct clk_parent_data pdata = { .index = index }; struct clk_hw *hw; int ret; @@ -85,11 +87,17 @@ struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, init.name = name; init.ops = &clk_fixed_factor_ops; init.flags = flags | CLK_IS_BASIC; - init.parent_names = &parent_name; + if (parent_name) + init.parent_names = &parent_name; + else + init.parent_data = &pdata; init.num_parents = 1; hw = &fix->hw; - ret = clk_hw_register(dev, hw); + if (dev) + ret = clk_hw_register(dev, hw); + else + ret = of_clk_hw_register(np, hw); if (ret) { kfree(fix); hw = ERR_PTR(ret); @@ -97,6 +105,14 @@ struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, return hw; } + +struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, + const char *name, const char *parent_name, unsigned long flags, + unsigned int mult, unsigned int div) +{ + return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, -1, flags, + mult, div); +} EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor); struct clk *clk_register_fixed_factor(struct device *dev, const char *name, @@ -143,11 +159,10 @@ static const struct of_device_id set_rate_parent_matches[] = { { /* Sentinel */ }, }; -static struct clk *_of_fixed_factor_clk_setup(struct device_node *node) +static struct clk_hw *_of_fixed_factor_clk_setup(struct device_node *node) { - struct clk *clk; + struct clk_hw *hw; const char *clk_name = node->name; - const char *parent_name; unsigned long flags = 0; u32 div, mult; int ret; @@ -165,30 +180,28 @@ static struct clk *_of_fixed_factor_clk_setup(struct device_node *node) } of_property_read_string(node, "clock-output-names", &clk_name); - parent_name = of_clk_get_parent_name(node, 0); if (of_match_node(set_rate_parent_matches, node)) flags |= CLK_SET_RATE_PARENT; - clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags, - mult, div); - if (IS_ERR(clk)) { + hw = __clk_hw_register_fixed_factor(NULL, node, clk_name, NULL, 0, + flags, mult, div); + if (IS_ERR(hw)) { /* - * If parent clock is not registered, registration would fail. * Clear OF_POPULATED flag so that clock registration can be * attempted again from probe function. */ of_node_clear_flag(node, OF_POPULATED); - return clk; + return ERR_CAST(hw); } - ret = of_clk_add_provider(node, of_clk_src_simple_get, clk); + ret = of_clk_add_hw_provider(node, of_clk_hw_simple_get, hw); if (ret) { - clk_unregister(clk); + clk_hw_unregister_fixed_factor(hw); return ERR_PTR(ret); } - return clk; + return hw; } /** @@ -203,17 +216,17 @@ CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock", static int of_fixed_factor_clk_remove(struct platform_device *pdev) { - struct clk *clk = platform_get_drvdata(pdev); + struct clk_hw *clk = platform_get_drvdata(pdev); of_clk_del_provider(pdev->dev.of_node); - clk_unregister_fixed_factor(clk); + clk_hw_unregister_fixed_factor(clk); return 0; } static int of_fixed_factor_clk_probe(struct platform_device *pdev) { - struct clk *clk; + struct clk_hw *clk; /* * This function is not executed when of_fixed_factor_clk_setup -- Sent by a computer through tubes