From patchwork Wed Feb 14 13:43:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10218931 X-Patchwork-Delegate: mturquette@baylibre.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE672601D7 for ; Wed, 14 Feb 2018 13:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC08C28517 for ; Wed, 14 Feb 2018 13:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0C2C28787; Wed, 14 Feb 2018 13:47:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C9D828517 for ; Wed, 14 Feb 2018 13:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030256AbeBNNri (ORCPT ); Wed, 14 Feb 2018 08:47:38 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:43684 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030362AbeBNNnv (ORCPT ); Wed, 14 Feb 2018 08:43:51 -0500 Received: by mail-wr0-f195.google.com with SMTP id b52so22171285wrd.10 for ; Wed, 14 Feb 2018 05:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xvmHmSrapQovZQJzIEqIpaecKemQ2ijAcfwElQXzau4=; b=ABxgKet5nBv2/vg7rp8LvTcff4QNqml63fBDzyx5svMZ2YRJZkDOUHiI8hewy0OwM2 rFfsB1niIj6rB19dXUK6v3aCvxpoe9KQrX7xNVISnL9f8vyj/7uEwdvp8bu2ld5MdFNB 263KSfwv07thCGbWjP6nzzTlMr+00YWAA1nidIyhNnXThh5UoJq5bI/YIrbTrvt+Klw1 zku0Z2kS3r7b9eqi5ixsL4ZMj7OM/fIGbmCtAwyvoPc1geNa+erISee1qut0i9Cs4p2S wesGtZi/56mcDnKgEi1/8NpRhjVnmTOMnx4tc8rVYunn33TKKbwWsBahtOSKfz8NyT4j zaXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xvmHmSrapQovZQJzIEqIpaecKemQ2ijAcfwElQXzau4=; b=SjraGVL7+Ont50YjtzJAlhMUswGoCYpM8ub/GSFplk7L6+MF7ThZAgKts4XZQhLOLu zIJL6CUrWN2GGhbGTGDVg3MeNJS+XsYEjLnSAKcp0YWe0vL3l35dCNoDdYJJ/Y7SFes7 roR0Hw5dBJBBE+3fQemlr3BJBw9fISy+fAq9SRxwAKFg6hsloy0Du+7cPqXwtiOLy4We YY7Q38QiumrrH4OpSJdSgPAR6awnr1FrPJ/RgAbcjeDo2kLJ8GTdyekbl/fTIs4BZD3e QqGOnMQ2WwzKTf//I3svwz80ki7DUrMPtwEe8W1YLUAesaPYjseY505RXQjuAui56xhx OHMg== X-Gm-Message-State: APf1xPArIxkpAqIeiyoPb8QO+fdDK/BBafrx8Mc3UrvuKSTTMXq8ZbP7 F1LzWVHs5Lb5UICD2nrPPGUv1A== X-Google-Smtp-Source: AH8x2251L/CypzSl7mO3hCQ0gAqRsHF2NdET8v6qjiZisiu28WHMIc82PXk3dFnoFIlNFQOzupYvyw== X-Received: by 10.223.209.3 with SMTP id a3mr4363219wri.27.1518615830357; Wed, 14 Feb 2018 05:43:50 -0800 (PST) Received: from boomer.lan (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id k5sm6337694wmg.47.2018.02.14.05.43.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 05:43:49 -0800 (PST) From: Jerome Brunet To: Michael Turquette , Stephen Boyd Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] clk: call the clock init() callback before any other ops callback Date: Wed, 14 Feb 2018 14:43:37 +0100 Message-Id: <20180214134340.17242-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180214134340.17242-1-jbrunet@baylibre.com> References: <20180214134340.17242-1-jbrunet@baylibre.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some clocks may need to initialize things, whatever it is, before being able to properly operate. Move the .init() call before any other callback, such recalc_rate() or get_phase(), so the clock is properly setup before being used. Signed-off-by: Jerome Brunet --- Stephen, Mike, This change is addressing a problem I have with clock driver I'm working on. This driver needs the .init() callback to run first is order to answer correctly .get_phase(). It does not address an existing issue, not one that I'm aware of at least. This is why I did not put a Fixes tag. In any case, it makes sense to run init before running anything else. drivers/clk/clk.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index cca05ea2c058..9d56be6ead39 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2929,6 +2929,17 @@ static int __clk_core_init(struct clk_core *core) core->orphan = true; } + /* + * optional platform-specific magic + * + * The .init callback is not used by any of the basic clock types, but + * exists for weird hardware that must perform initialization magic. + * Please consider other ways of solving initialization problems before + * using this callback, as its use is discouraged. + */ + if (core->ops->init) + core->ops->init(core->hw); + /* * Set clk's accuracy. The preferred method is to use * .recalc_accuracy. For simple clocks and lazy developers the default @@ -3006,17 +3017,6 @@ static int __clk_core_init(struct clk_core *core) } } - /* - * optional platform-specific magic - * - * The .init callback is not used by any of the basic clock types, but - * exists for weird hardware that must perform initialization magic. - * Please consider other ways of solving initialization problems before - * using this callback, as its use is discouraged. - */ - if (core->ops->init) - core->ops->init(core->hw); - kref_init(&core->ref); out: clk_pm_runtime_put(core);