Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3673560ybk; Tue, 19 May 2020 10:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoUcoBsQJbfwwbh8lpZQKp+UpdmWhlBJGsu6bies/m+kZ3xfU87RnsFsg77sIyD/exZh8e X-Received: by 2002:a05:6402:154b:: with SMTP id p11mr19049648edx.355.1589908359755; Tue, 19 May 2020 10:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589908359; cv=none; d=google.com; s=arc-20160816; b=fz11xQEmwbbIjrUNmTpMXf1H+ukcwYeDhDrgV4JrnltqxXarTyDkdqopFu2ZLNex7v s2MJPn5hHGDjmMJTYZ5oZ/X1qYWbOL2/Cx6JffDffheaj0MacZ+QFD7uFBxiYA/bOVDp 987pnKi3UwJ32huUbDvwiv7uXu1SDVOzEf0gXxnKB1zUh0b3eqWfNYv3foAlC35yUcr3 W4Y5UX0835l40k0oMq0HAP4VUBmAND5vA7ed9G/BpxlaZzBKVS8MH9VyH4TI1m1Gh1bZ qYXhnQSOwYbyQgZHpJfgAAuuvBwIWQYprtnK6SO9dl6He+Ro2+IXtudbtnurE3x+v6va yurQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Xs2DZn2lRCTad+sBiNc+BctIq4JOr+bWIH96SVwqx0c=; b=iQM+uAToaPAUdQEdsRksQIjqLEvPBnLpYRCd6fdVFh8yXoLIRykNsBKKivS1CM0Qoe RluOhW00DQOiQrHXiR6PuSwQimmI5E74z7rrZwYN7pUI9LLVCcHnKibw/EaqFCBQ9kIP Jkkzd3prf1FczuPQ9fNaHqLnf1/HzEA+lZ+Pr7ZgXOGgldrMZVJ3+Ne/upUdkmGgro+D CJbBzyToYsQ+hFn3Uk5vWa6XlssxhhzZKRv23HFDnzQmGO5ePk8hEMCMICpVETtaYAOR YvYd95VsvmL2o2Afb+1SXl1WW8y8occUTOkpfScvmqszOAoBHbYH8Uox6yII1MfuuRSO uDuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=fqL0h3c2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qh14si266578ejb.171.2020.05.19.10.12.16; Tue, 19 May 2020 10:12:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=fqL0h3c2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729267AbgESRKx (ORCPT + 99 others); Tue, 19 May 2020 13:10:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729197AbgESRKx (ORCPT ); Tue, 19 May 2020 13:10:53 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143E9C08C5C0 for ; Tue, 19 May 2020 10:10:53 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id f13so3819592wmc.5 for ; Tue, 19 May 2020 10:10:53 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=Xs2DZn2lRCTad+sBiNc+BctIq4JOr+bWIH96SVwqx0c=; b=fqL0h3c2Xp2hoK5XrJG/CvNKsMpLGHx9LRNboyPqdPp9c/5mvU5A/y/Q8stJOThqjp keJv+36/P7d+MxJQZ4QYLzAw4eBJAAZg8lsHyPzcKnM9wgIhKZ/CMnK5ef/pC3Xzrp79 Op1JvCnUuMY/QJIW/Av/ffefwKvq2w4hy1GQYdEadYCDLE7AG4YqBWAzbuEP5KboSWAB iIUo+FMMQ3iNkPdpgLHWgwlZHvZE/+cQjkn8YUznKN9v9Zk9uSXUss8rBHFGDD0XP4ER pGyxboWn5rpsi/O3glHXHYFEf5jSypil8wxw2WNBVbsf9HfvJ9jqp+4QQXWNOiuTWHGb d5WA== 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:mime-version :content-transfer-encoding; bh=Xs2DZn2lRCTad+sBiNc+BctIq4JOr+bWIH96SVwqx0c=; b=ZKVLR+26Eood1mR9+Fxn7ytufKsOeAdKyph5WFdETjDNfBuT7OL+etHaO5CB6ihCfJ 2ZE2SpKjtyJaFUks4bJOPPmdnR0ErVLZDTDCOzz+cmn76GVE5HI4hROy1ETgUKbPKQDE 1UyPMsn0ZCLtG0yNo6pDLe52CM0aYl/SKwtqWib89Sy8R6Dhbh+PqytJopGGzvDa+YZA s/HIqWpZb39A7VwmuGcr1ZVyO1n1CjKF0BcSFAOYmVK8jOKSpxEgRIa9+tkrG1uPq6Mm V5XYxD2ukpKaKA5GqYd71saq2uYnh8d+jY5pphxOMnBRyloqQCDeP5HGhzUFRv/03vV0 whYw== X-Gm-Message-State: AOAM530XBpxD7lHLBko/5QYF/ECY3ZwEsYpHf3NP6fxB/eyKai1wnf1J 8YLu4szOqp7Z/u2OycvcHk+skUljwWI= X-Received: by 2002:a1c:23d2:: with SMTP id j201mr406894wmj.48.1589907886459; Tue, 19 May 2020 10:04:46 -0700 (PDT) Received: from starbuck.lan (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id b19sm352685wmd.26.2020.05.19.10.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 10:04:45 -0700 (PDT) From: Jerome Brunet To: Stephen Boyd , Martin Blumenstingl Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: add api to get clk consummer from clk_hw Date: Tue, 19 May 2020 19:04:40 +0200 Message-Id: <20200519170440.294601-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clk_register() is deprecated. Using 'clk' member of struct clk_hw is discouraged. With this constrainst, it is difficult for driver to register clocks using the clk_hw API and then use the clock with the consummer API This add a simple helper, clk_hw_get_clk(), to get a struct clk from a struct clk_hw. Like other clk_get() variant, each call to this helper must be balanced with a call to clk_put(). Cc: Martin Blumenstingl Signed-off-by: Jerome Brunet --- drivers/clk/clk.c | 17 +++++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 6fd23ce3cb03..d9946e192cbc 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3625,6 +3625,23 @@ struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, return clk; } +/** + * clk_hw_get_clk: get clk consummer given an clk_hw + * @hw: clk_hw associated with the clk being consumed + * + * Returns: new clk consummer + * This is the function to be used by providers which need + * to get a consummer clk and act on the clock element + * Calls to this function must be balanced with calls clk_put() + */ +struct clk *clk_hw_get_clk(struct clk_hw *hw) +{ + struct device *dev = hw->core->dev; + + return clk_hw_create_clk(dev, hw, dev_name(dev), NULL); +} +EXPORT_SYMBOL(clk_hw_get_clk); + static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist) { const char *dst; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index bd1ee9039558..a8f466bdda1a 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -1088,6 +1088,7 @@ static inline struct clk_hw *__clk_get_hw(struct clk *clk) return (struct clk_hw *)clk; } #endif +struct clk *clk_hw_get_clk(struct clk_hw *hw); unsigned int clk_hw_get_num_parents(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw); struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw, -- 2.25.4