Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp926453imd; Thu, 1 Nov 2018 07:42:27 -0700 (PDT) X-Google-Smtp-Source: AJdET5eOnKITMH9RRI69bqgCT01yFXkACRCUWqFc6vesqdZxlkYJ4aX3wAvHSjs898Vzgjc27g+P X-Received: by 2002:a62:9c8c:: with SMTP id u12-v6mr7922026pfk.162.1541083347121; Thu, 01 Nov 2018 07:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541083347; cv=none; d=google.com; s=arc-20160816; b=xm5XcIuhHPWaa3lHkW58WOyjs6SgjljMdImlIEoQsPE2qSJGWmHXGUeYU9x/J/azKg XfmdRW6tXRNFk+l5xWHpBtEkXE6bhm7Uv2XCfxivRMX2jWD2q1BYKf/1b9BxtOaWG3XI Syjlz20+zw+xTAQuTCyI1hSaAnglX87S1+L7814D9AwaxQOMCcr+qCOjSI26PSxHaHkd JFxYDM4NvHdBlsmQ8bvxo0bcZBpqya8YM2Pwmj7m4a4+bv5tdL5nPyWaTUU0+jCqkZlj bl0AKUAQ8pNgjW7riwj0hfUxF+uc55Xj9hK1tKO0aLcTaZv3+auyDmgsPsqFFcd1BlVq qdEQ== 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=VimP1qjpqygKIez+BYIo7GsWa4+fe+wj595JxxLPTUg=; b=E3Dmg2AfpmzRyDcgSVqaNONToJK21uMataO4j1NK8W9tyspvy4H1iYJNh1hXEikOhp 2kB97iXGfZtOxw33m2KpvH7v47gWXEzFMZ+6K3kRiQcCIxMjWm05kOcaLNogAbbEw+iK 3IKoCZobxSH2Zv9dZEd1OZlgs15UFhve7zISAmRhWiEilyThPrfEKo5kumuPC4Fvusl9 DEP+r/r0rB/EMeAlzw3kj4XAQQTZI6p8e4o9QAEW/DOvVBx7L9uNGBCitgJgijVDzwqh AUm9xoL8ek/kZfpRizSvnZn1p3gx9ridL1QRKDECzZZyOLieaLOSEMincfrvSQ/I4bqi bZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nkvtKgLq; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si32798158plq.243.2018.11.01.07.42.11; Thu, 01 Nov 2018 07:42:27 -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=@gmail.com header.s=20161025 header.b=nkvtKgLq; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728858AbeKAXoJ (ORCPT + 99 others); Thu, 1 Nov 2018 19:44:09 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36188 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbeKAXoI (ORCPT ); Thu, 1 Nov 2018 19:44:08 -0400 Received: by mail-lj1-f195.google.com with SMTP id s15-v6so18290533lji.3; Thu, 01 Nov 2018 07:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VimP1qjpqygKIez+BYIo7GsWa4+fe+wj595JxxLPTUg=; b=nkvtKgLqul6YhnnlJcG8kHjNcRTTXWAuNWrvW6UJVlQSMG+GprQ+JBxkO2tlO7N7f+ G7POu80hzGPSiYvWqZzpU4FFWYj1OOkFR03Xhqo8EpsLKa1k2v4heGRR82KMeHnf2u1m 4GIAcK8hIYOM+ANZBZZk5xLuYCZKc96QX2aGDYN35mhlgrhr14npKaJyntx90mCq7L3L wCX1XZse9NchuOxEmzJaKZAjuTRhDBLv57SjJMvmSDMoNxJKXafDcob+uTDYhgLxnddJ 0bZ64VImrJQqAKds1WmlK4v+acyJoaq0Sh3m4dopJbK8338Xb/pOfYiKsZ+AZtuU63gK mW7A== 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:mime-version:content-transfer-encoding; bh=VimP1qjpqygKIez+BYIo7GsWa4+fe+wj595JxxLPTUg=; b=BiF+RkxhxgQ+XXgj/MsTlxyh8o+yxfJMtluruut4o9CkYzyY0VuKQPJ0sCZ1/f4T4A tG8ReDd3tMJX9KRdlhWtqlQNjLgsP+m42PJ5Noq0tNFV4sXHMSP1FAkATJUNjfqr6DDv xQUKbn1UPvkJbTQsZ15PzTctUZ58J3xTndC/Bgf+YrMaMKX/1iSplWsoZgWZxFgAUqYq L3LNCw+Ykhw/iA0TyOwyFpZWNZEU9HQjI4CLhhGJnOMi6zCvTILUDQlYcOonSJPnoNFt a+nEFjk1Fr0IR7P/0aeneTptZo2urmpljxymX/LDpCPyb5jX7CkAf8wIJ+eLSQ/YCQiF DPkw== X-Gm-Message-State: AGRZ1gKV9Dd8zy1QthJJlvTYzKCk4M76KtmfRS/RPvncOnPwXxIm4REP ajaLlLhFWk0ZTBDM/pXY9twCDd3nJhg= X-Received: by 2002:a2e:3012:: with SMTP id w18-v6mr4945282ljw.75.1541083250445; Thu, 01 Nov 2018 07:40:50 -0700 (PDT) Received: from neopili.qtec.com (cpe.xe-3-0-1-778.vbrnqe10.dk.customer.tdc.net. [80.197.57.18]) by smtp.gmail.com with ESMTPSA id a9sm404870lfa.19.2018.11.01.07.40.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 07:40:48 -0700 (PDT) From: Ricardo Ribalda Delgado To: Stephen Boyd , Alan Tull , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Delgado Subject: [PATCH 2/5] clk: Create devm_of_clk_add_provider Date: Thu, 1 Nov 2018 15:40:41 +0100 Message-Id: <20181101144044.11495-3-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181101144044.11495-1-ricardo.ribalda@gmail.com> References: <20181101144044.11495-1-ricardo.ribalda@gmail.com> 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 Implement devm_ flavour of of_clk_add_provider. This will help fixing of_node_get-put imbalances. Signed-off-by: Ricardo Ribalda Delgado --- Documentation/driver-model/devres.txt | 1 + drivers/clk/clk.c | 29 ++++++++++++++++++++++----- include/linux/clk-provider.h | 11 ++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 43681ca0837f..a8e066d42355 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -237,6 +237,7 @@ CLOCK devm_clk_get() devm_clk_put() devm_clk_hw_register() + devm_of_clk_add_provider() devm_of_clk_add_hw_provider() DMA diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index cd3117e66ab8..d315ffa6a32f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3789,10 +3789,12 @@ static void devm_of_clk_release_provider(struct device *dev, void *res) of_clk_del_provider(*(struct device_node **)res); } -int devm_of_clk_add_hw_provider(struct device *dev, - struct clk_hw *(*get)(struct of_phandle_args *clkspec, - void *data), - void *data) +static int __devm_of_clk_add_provider(struct device *dev, + struct clk *(*clk_src_get)(struct of_phandle_args *clkspec, + void *data), + struct clk_hw *(*get)(struct of_phandle_args *clkspec, + void *data), + void *data) { struct device_node **ptr, *np; int ret; @@ -3803,7 +3805,7 @@ int devm_of_clk_add_hw_provider(struct device *dev, return -ENOMEM; np = dev->of_node; - ret = of_clk_add_hw_provider(np, get, data); + ret = __of_clk_add_provider(np, clk_src_get, get, data); if (!ret) { *ptr = np; devres_add(dev, ptr); @@ -3813,6 +3815,23 @@ int devm_of_clk_add_hw_provider(struct device *dev, return ret; } + +int devm_of_clk_add_provider(struct device *dev, + struct clk *(*clk_src_get)(struct of_phandle_args *clkspec, + void *data), + void *data) +{ + return __devm_of_clk_add_provider(dev, clk_src_get, NULL, data); +} +EXPORT_SYMBOL_GPL(devm_of_clk_add_provider); + +int devm_of_clk_add_hw_provider(struct device *dev, + struct clk_hw *(*get)(struct of_phandle_args *clkspec, + void *data), + void *data) +{ + return __devm_of_clk_add_provider(dev, NULL, get, data); +} EXPORT_SYMBOL_GPL(devm_of_clk_add_hw_provider); /** diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 08b1aa70a38d..bbd86fe656ef 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -905,6 +905,10 @@ int of_clk_add_hw_provider(struct device_node *np, struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), void *data); +int devm_of_clk_add_provider(struct device *dev, + struct clk *(*clk_src_get)(struct of_phandle_args *clkspec, + void *data), + void *data); int devm_of_clk_add_hw_provider(struct device *dev, struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), @@ -939,6 +943,13 @@ static inline int of_clk_add_hw_provider(struct device_node *np, { return 0; } +static inline int devm_of_clk_add_provider(struct device *dev, + struct clk *(*clk_src_get)(struct of_phandle_args *clkspec, + void *data), + void *data) +{ + return 0; +} static inline int devm_of_clk_add_hw_provider(struct device *dev, struct clk_hw *(*get)(struct of_phandle_args *clkspec, void *data), -- 2.19.1