Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp685681yba; Fri, 12 Apr 2019 11:33:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnEtvSyGWJyL+sJ3FKWhBcHO8p7pMhVFSdY6JT8vTheDoPDbeeb3AzmlJlCC4LpcofQte1 X-Received: by 2002:a65:44cd:: with SMTP id g13mr47770646pgs.258.1555094038841; Fri, 12 Apr 2019 11:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555094038; cv=none; d=google.com; s=arc-20160816; b=zhfvpZP5cqEGuzqAXT6w8BXwAGoPMZTDzV1XPVoJxN0oV3xkuqb+rzFGXq2lSoHMwC u/r3fTYAOFwVn2cvBI4DBCgdV6kHTWkYmxnFJX8NlR3CIqAwhm9vHN+DB22rMZueKlKj vZx0v3dtQnjwXbUMsUMcvlhZqFsbEy66QKxHkzr0GbU009nwlICxjk+xSRJ5NcTXraLU ZR4WTNBVp4Uu2bQXYcqebwlvui26YyNFbBwGz0Q3SAtp3k4INxYbYg0yk4JpisbDTJlU eRsTM9ZA/Cc3ojSh/+rDBN7Q1vfL2s0wKAuKd2JM9ShUez2O3zvq3JMg1PXSFAw1KGy4 5X8Q== 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=5po0TmgTNfE29aN2wM2KlChCJEKBVhMEQsJ/AnYLaXc=; b=Y8YHdbQukbl+1Stb+RDJyYzardgAB43tSkNppgNnEN+pz0Qax4g6EHeo80mWJCM8Lw 4vbvI+X2+k0NMnVeFgUH5vUxQm/V28NZlPcpTneAyi4N0IVy4eo/KUJwKai78PV2TM4u DuF0BZrTOgFdgZUAXb1xhfJufiPB9jUT3cC5y/NxstxoyJra8mfxv4dbgTlyvSdQmxbl iDd4k78VrwWBm+XXB+/gEN6749xsDATVP+L4bz0n8J82Yga1KWYwb4BPHF6v6IJo4uag l+RSodamHzDzvz3qIlUcY2CaaMLsugBC3SSZDUIsOHi8GeenoR7wI9zVyNxpojqCrsDB teUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DclFyroe; 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 73si30393206pfs.186.2019.04.12.11.33.42; Fri, 12 Apr 2019 11:33:58 -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=DclFyroe; 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 S1727044AbfDLSby (ORCPT + 99 others); Fri, 12 Apr 2019 14:31:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:50334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726914AbfDLSbx (ORCPT ); Fri, 12 Apr 2019 14:31:53 -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 26064218C3; Fri, 12 Apr 2019 18:31:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555093912; bh=9nrE2eN80xxKdJ9WieNmrYl4QLOjjhrAG6XUmVRgGZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DclFyroe13Qb1lWk3Qx7ERAxnNpTSQ0uc2RtGeQxHrgB+l7h7OArWZ0ydeVjIAZ10 woko8Z0r7yUL+hrH2NsIqPX4R0FwtASEo2c8h9aJyblqCrMUtcGl7amsJcCW032pEI FA5H72WRpQs89ZhySCLtBBiVQCz9nUFkL2rgNMd4= 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 2/9] clkdev: Move clk creation outside of 'clocks_mutex' Date: Fri, 12 Apr 2019 11:31:43 -0700 Message-Id: <20190412183150.102131-3-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 We don't need to hold the 'clocks_mutex' here when we're creating a clk pointer from a clk_lookup structure. Instead, we just need to make sure that the lookup doesn't go away while we dereference the lookup pointer to extract the clk_hw pointer out of it. Let's move things around slightly so that we have a new function to get the clk_hw out of the lookup with the right locking and then chain the two together for what used to be __clk_get_sys(). 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/clkdev.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 6e787cc9e5b9..6f65bde696da 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -72,25 +72,26 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) return cl; } -static struct clk *__clk_get_sys(struct device *dev, const char *dev_id, - const char *con_id) +static struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id) { struct clk_lookup *cl; - struct clk *clk = NULL; + struct clk_hw *hw = ERR_PTR(-ENOENT); mutex_lock(&clocks_mutex); - cl = clk_find(dev_id, con_id); - if (!cl) - goto out; - - clk = clk_hw_create_clk(dev, cl->clk_hw, dev_id, con_id); - if (IS_ERR(clk)) - cl = NULL; -out: + if (cl) + hw = cl->clk_hw; mutex_unlock(&clocks_mutex); - return cl ? clk : ERR_PTR(-ENOENT); + return hw; +} + +static struct clk *__clk_get_sys(struct device *dev, const char *dev_id, + const char *con_id) +{ + struct clk_hw *hw = clk_find_hw(dev_id, con_id); + + return clk_hw_create_clk(dev, hw, dev_id, con_id); } struct clk *clk_get_sys(const char *dev_id, const char *con_id) -- Sent by a computer through tubes