* [PATCH 1/2] of: Make const the device node pointers in of_clk_get and of_node_put
2014-11-09 18:28 [PATCH 0/2] of: Fix some 'const' problems Jean-Francois Moine
@ 2014-11-08 18:33 ` Jean-Francois Moine
2014-11-09 18:50 ` Russell King - ARM Linux
2014-11-09 11:38 ` [PATCH 2/2] ASoC: Remove useless casts Jean-Francois Moine
1 sibling, 1 reply; 5+ messages in thread
From: Jean-Francois Moine @ 2014-11-08 18:33 UTC (permalink / raw)
To: linux-arm-kernel
Some device nodes are sometimes referenced by const pointers.
This patch avoids to cast these pointers when calling the functions
of_clk_get() and of_node_put().
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
drivers/clk/clkdev.c | 2 +-
drivers/of/dynamic.c | 2 +-
include/linux/clk.h | 4 ++--
include/linux/of.h | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index da4bda8..eaee11e 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -53,7 +53,7 @@ struct clk *of_clk_get_by_clkspec(struct of_phandle_args *clkspec)
return clk;
}
-struct clk *of_clk_get(struct device_node *np, int index)
+struct clk *of_clk_get(const struct device_node *np, int index)
{
struct of_phandle_args clkspec;
struct clk *clk;
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index f297891..64eb5ba 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -34,7 +34,7 @@ EXPORT_SYMBOL(of_node_get);
* @node: Node to dec refcount, NULL is supported to simplify writing of
* callers
*/
-void of_node_put(struct device_node *node)
+void of_node_put(const struct device_node *node)
{
if (node)
kobject_put(&node->kobj);
diff --git a/include/linux/clk.h b/include/linux/clk.h
index c7f258a..4e077a4 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -425,11 +425,11 @@ struct device_node;
struct of_phandle_args;
#if defined(CONFIG_OF) && defined(CONFIG_COMMON_CLK)
-struct clk *of_clk_get(struct device_node *np, int index);
+struct clk *of_clk_get(const struct device_node *np, int index);
struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
#else
-static inline struct clk *of_clk_get(struct device_node *np, int index)
+static inline struct clk *of_clk_get(const struct device_node *np, int index)
{
return ERR_PTR(-ENOENT);
}
diff --git a/include/linux/of.h b/include/linux/of.h
index 6545e7a..b738681 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -95,14 +95,14 @@ static inline int of_node_is_attached(struct device_node *node)
#ifdef CONFIG_OF_DYNAMIC
extern struct device_node *of_node_get(struct device_node *node);
-extern void of_node_put(struct device_node *node);
+extern void of_node_put(const struct device_node *node);
#else /* CONFIG_OF_DYNAMIC */
/* Dummy ref counting routines - to be implemented later */
static inline struct device_node *of_node_get(struct device_node *node)
{
return node;
}
-static inline void of_node_put(struct device_node *node) { }
+static inline void of_node_put(const struct device_node *node) { }
#endif /* !CONFIG_OF_DYNAMIC */
#ifdef CONFIG_OF
--
2.1.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ASoC: Remove useless casts
2014-11-09 18:28 [PATCH 0/2] of: Fix some 'const' problems Jean-Francois Moine
2014-11-08 18:33 ` [PATCH 1/2] of: Make const the device node pointers in of_clk_get and of_node_put Jean-Francois Moine
@ 2014-11-09 11:38 ` Jean-Francois Moine
1 sibling, 0 replies; 5+ messages in thread
From: Jean-Francois Moine @ 2014-11-09 11:38 UTC (permalink / raw)
To: linux-arm-kernel
There is no need to cast the cpu_of_node or codec_of_node of the
dai_links when calling of_put_node.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
---
sound/soc/generic/simple-card.c | 7 ++-----
sound/soc/samsung/odroidx2_max98090.c | 4 ++--
sound/soc/ux500/mop500.c | 6 ++----
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index cd49d50..3e3fec4 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -457,16 +457,13 @@ static int asoc_simple_card_unref(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
struct snd_soc_dai_link *dai_link;
- struct device_node *np;
int num_links;
for (num_links = 0, dai_link = card->dai_link;
num_links < card->num_links;
num_links++, dai_link++) {
- np = (struct device_node *) dai_link->cpu_of_node;
- of_node_put(np);
- np = (struct device_node *) dai_link->codec_of_node;
- of_node_put(np);
+ of_node_put(dai_link->cpu_of_node);
+ of_node_put(dai_link->codec_of_node);
}
return 0;
}
diff --git a/sound/soc/samsung/odroidx2_max98090.c b/sound/soc/samsung/odroidx2_max98090.c
index 3c8f604..d7640e7 100644
--- a/sound/soc/samsung/odroidx2_max98090.c
+++ b/sound/soc/samsung/odroidx2_max98090.c
@@ -153,8 +153,8 @@ static int odroidx2_audio_remove(struct platform_device *pdev)
snd_soc_unregister_card(card);
- of_node_put((struct device_node *)odroidx2_dai[0].cpu_of_node);
- of_node_put((struct device_node *)odroidx2_dai[0].codec_of_node);
+ of_node_put(odroidx2_dai[0].cpu_of_node);
+ of_node_put(odroidx2_dai[0].codec_of_node);
return 0;
}
diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index b3b66aa..ea9ba284 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -64,11 +64,9 @@ static void mop500_of_node_put(void)
for (i = 0; i < 2; i++) {
if (mop500_dai_links[i].cpu_of_node)
- of_node_put((struct device_node *)
- mop500_dai_links[i].cpu_of_node);
+ of_node_put(mop500_dai_links[i].cpu_of_node);
if (mop500_dai_links[i].codec_of_node)
- of_node_put((struct device_node *)
- mop500_dai_links[i].codec_of_node);
+ of_node_put(mop500_dai_links[i].codec_of_node);
}
}
--
2.1.3
^ permalink raw reply related [flat|nested] 5+ messages in thread