Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4297027imu; Mon, 28 Jan 2019 22:13:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN4igUMoYKu+u6H8DfgL+MR3CIIyfhHZXW6hC0yssZ/iAF3NT7Is/9c2HSXrJh/YTPMe4lA7 X-Received: by 2002:a65:4381:: with SMTP id m1mr22131737pgp.358.1548742395468; Mon, 28 Jan 2019 22:13:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548742395; cv=none; d=google.com; s=arc-20160816; b=xu9MME6Boj5FbcuU2dT361h9719F0PWDmg9WxmVkEJ95YlQ3PZS1BmUWzm6g4dCUWb Z54qDiUaYZWjedlW0nSICz90MPb0Lzxl+RK5S3p5WeE/MzdFgJ1Bg7l8fMaWXvshxxUH +/78E+AxqqOJaaDJll93nwSnNZ8bJIpdmqes3nkMHHIVQd7A+eKpNHSAkbRjJY62VbiZ YnKcOtLvx9+Hn7ndtKKqrud3nWIUnEKt4/xryFt0nfFXuz2MFC5hn2OF6+WbGEyENF82 NyIC2+pCjQX2f2HrB/YLOTFst8svQK0iG9w8oUHBfTf0qfSs4as7ekir9Ox0KO3yqEj3 A88w== 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=wiGGbueO4pBzNplyW1O3CKrUP/LmRNmHUB1ybFPUga4=; b=maM1G3pgkUyf+69gPb9Hl7Fnks+iNegf5hr1yV4lyAUNpgfpTqDNJTac7CQ+bmiZr4 hbQ4rF1GqilSgw68x4XDT6uCrrwBIJxl/nzdsvsBRe+LCmWCG6KJUXi6yEVuYoN0a2Nt KUISwxik6z//4r0c6LHunj52VdBxgn5fbg0hCDoRR6sEtQ2Hhn113oIvagzXqN8/5Hfx X5xTEbWVrBTTmSwr6pj77zOQq/5yjlKiUkOSzCpfpJAfhg8t89AHqKJs1Cjh8ZG4X0fT 6n7t3COwFR7MgA65nE3KafXdL4/gT5wJ00eUdWK5IopqCqzCGpXflpeXONtQdA5+1Ue6 TS/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V+Jo7mWU; 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 g11si15859959pgu.347.2019.01.28.22.13.00; Mon, 28 Jan 2019 22:13:15 -0800 (PST) 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=V+Jo7mWU; 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 S1727709AbfA2GLB (ORCPT + 99 others); Tue, 29 Jan 2019 01:11:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:33430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfA2GKY (ORCPT ); Tue, 29 Jan 2019 01:10:24 -0500 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 9120E21841; Tue, 29 Jan 2019 06:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548742223; bh=Z848HCBtnzeyslpUOhB1zGR5r1IbxympifhvWGT6J3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+Jo7mWUqfz1ur1wEqNpUO+8yeyp2rRAvnsgH9ICjO599S1Hyz+Mw16aIXCWFpYI6 Z4f9BckDZfClGF0Lls2HaCYLOSzWbIWVBzQfUSCG4JeHbPwkou36Ck6fwLm1gqOix7 4Fq6H11JRg0KwEziBjZu7VOl+CZwN15sTo+HBhCU= From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: Miquel Raynal , linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Jerome Brunet , Russell King Subject: [PATCH 3/9] clk: core: clarify the check for runtime PM Date: Mon, 28 Jan 2019 22:10:15 -0800 Message-Id: <20190129061021.94775-4-sboyd@kernel.org> X-Mailer: git-send-email 2.20.1.495.gaa96b0ce6b-goog In-Reply-To: <20190129061021.94775-1-sboyd@kernel.org> References: <20190129061021.94775-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 From: Miquel Raynal Currently, the core->dev entry is populated only if runtime PM is enabled. Doing so prevents accessing the device structure in any case. Keep the same logic but instead of using the presence of core->dev as the only condition, also check the status of pm_runtime_enabled(). Then, we can set the core->dev pointer at any time as long as a device structure is available. This change will help supporting device links in the clock subsystem. Signed-off-by: Miquel Raynal Cc: Jerome Brunet Cc: Russell King Cc: Michael Turquette [sboyd@kernel.org: Change to a boolean flag] Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 5d82cf25bb29..01cdb9ae03fa 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -60,6 +60,7 @@ struct clk_core { struct clk_core *new_child; unsigned long flags; bool orphan; + bool rpm_enabled; unsigned int enable_count; unsigned int prepare_count; unsigned int protect_count; @@ -95,9 +96,9 @@ struct clk { /*** runtime pm ***/ static int clk_pm_runtime_get(struct clk_core *core) { - int ret = 0; + int ret; - if (!core->dev) + if (!core->rpm_enabled) return 0; ret = pm_runtime_get_sync(core->dev); @@ -106,7 +107,7 @@ static int clk_pm_runtime_get(struct clk_core *core) static void clk_pm_runtime_put(struct clk_core *core) { - if (!core->dev) + if (!core->rpm_enabled) return; pm_runtime_put_sync(core->dev); @@ -226,7 +227,7 @@ static bool clk_core_is_enabled(struct clk_core *core) * taking enable spinlock, but the below check is needed if one tries * to call it from other places. */ - if (core->dev) { + if (core->rpm_enabled) { pm_runtime_get_noresume(core->dev); if (!pm_runtime_active(core->dev)) { ret = false; @@ -236,7 +237,7 @@ static bool clk_core_is_enabled(struct clk_core *core) ret = core->ops->is_enabled(core->hw); done: - if (core->dev) + if (core->rpm_enabled) pm_runtime_put(core->dev); return ret; @@ -3391,7 +3392,8 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw) core->ops = hw->init->ops; if (dev && pm_runtime_enabled(dev)) - core->dev = dev; + core->rpm_enabled = true; + core->dev = dev; if (dev && dev->driver) core->owner = dev->driver->owner; core->hw = hw; -- Sent by a computer through tubes