Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1231949 > unrolled thread

[PATCH 1/1] clk: add devm_of_clk_get() and devm_of_clk_get_by_name() functions

Started byPaul Osmialowski <newchief@king.net.pl>
First post2015-09-24 10:40 +0200
Last post2015-09-29 01:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/1] clk: add devm_of_clk_get() and devm_of_clk_get_by_name() functions Paul Osmialowski <newchief@king.net.pl> - 2015-09-24 10:40 +0200
    Re: [PATCH 1/1] clk: add devm_of_clk_get() and  devm_of_clk_get_by_name() functions Stephen Boyd <sboyd@codeaurora.org> - 2015-09-29 01:20 +0200

#1231949 — [PATCH 1/1] clk: add devm_of_clk_get() and devm_of_clk_get_by_name() functions

FromPaul Osmialowski <newchief@king.net.pl>
Date2015-09-24 10:40 +0200
Subject[PATCH 1/1] clk: add devm_of_clk_get() and devm_of_clk_get_by_name() functions
Message-ID<qcael-6bA-11@gated-at.bofh.it>
From: Paul Osmialowski <pawelo@king.net.pl>

These two functions were added to ease management of clocks obtained
from OF device nodes.

Signed-off-by: Paul Osmialowski <pawelo@king.net.pl>
---
 drivers/clk/clk-devres.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/clk.h      | 20 ++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
index 8f57154..197075a 100644
--- a/drivers/clk/clk-devres.c
+++ b/drivers/clk/clk-devres.c
@@ -34,6 +34,52 @@ struct clk *devm_clk_get(struct device *dev, const char *id)
 }
 EXPORT_SYMBOL(devm_clk_get);
 
+#ifdef CONFIG_OF
+
+struct clk *devm_of_clk_get(struct device *dev, struct device_node *np,
+			    int index)
+{
+	struct clk **ptr, *clk;
+
+	ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return ERR_PTR(-ENOMEM);
+
+	clk = of_clk_get(np, index);
+	if (!IS_ERR(clk)) {
+		*ptr = clk;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return clk;
+}
+EXPORT_SYMBOL(devm_of_clk_get);
+
+struct clk *devm_of_clk_get_by_name(struct device *dev, struct device_node *np,
+				    const char *name)
+{
+	struct clk **ptr, *clk;
+
+	ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return ERR_PTR(-ENOMEM);
+
+	clk = of_clk_get_by_name(np, name);
+	if (!IS_ERR(clk)) {
+		*ptr = clk;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return clk;
+}
+EXPORT_SYMBOL(devm_of_clk_get_by_name);
+
+#endif /* CONFIG_OF */
+
 static int devm_clk_match(struct device *dev, void *res, void *data)
 {
 	struct clk **c = res;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 0df4a51..d7763f1 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -504,4 +504,24 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np,
 }
 #endif
 
+#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) && defined(CONFIG_HAVE_CLK)
+struct clk *devm_of_clk_get(struct device *dev, struct device_node *np,
+			    int index);
+struct clk *devm_of_clk_get_by_name(struct device *dev, struct device_node *np,
+				    const char *name);
+#else
+static inline struct clk *devm_of_clk_get(struct device *dev,
+					  struct device_node *np,
+					  int index)
+{
+	return ERR_PTR(-ENOENT);
+}
+static inline struct clk *devm_of_clk_get_by_name(struct device *dev,
+						  struct device_node *np,
+						  const char *name)
+{
+	return ERR_PTR(-ENOENT);
+}
+#endif
+
 #endif
-- 
2.4.9

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1234567 — Re: [PATCH 1/1] clk: add devm_of_clk_get() and devm_of_clk_get_by_name() functions

FromStephen Boyd <sboyd@codeaurora.org>
Date2015-09-29 01:20 +0200
SubjectRe: [PATCH 1/1] clk: add devm_of_clk_get() and devm_of_clk_get_by_name() functions
Message-ID<qdPS9-5yM-3@gated-at.bofh.it>
In reply to#1231949
On 09/24, Paul Osmialowski wrote:
> From: Paul Osmialowski <pawelo@king.net.pl>
> 
> These two functions were added to ease management of clocks obtained
> from OF device nodes.
> 

All the words that were in the cover letter for this single patch
should have been here in the commit text instead. If we were to
look back on this commit text a year from now we'd learn that
things got easier for clock management, but not *why* things got
easier.

Cover letters for single patches are practically useless by the
way. That's because they duplicate the diffstat that is already
in the patch and summarize the subject of the patch. Please don't
send cover letters for single patches.

> diff --git a/include/linux/clk.h b/include/linux/clk.h
> index 0df4a51..d7763f1 100644
> --- a/include/linux/clk.h
> +++ b/include/linux/clk.h
> @@ -504,4 +504,24 @@ static inline struct clk *of_clk_get_by_name(struct device_node *np,
>  }
>  #endif
>  
> +#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK) && defined(CONFIG_HAVE_CLK)

Doesn't CONFIG_COMMON_CLK imply CONFIG_HAVE_CLK? So drop that
config check? Also, devm_*() functions are documented in
Documentation, so please update that file too, if it even makes
sense to have this new API.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web