All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] of: Fix constantness of of_n_size_cells
@ 2014-08-22 17:43 Geoff Levand
       [not found] ` <cover.1408729200.git.geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Geoff Levand @ 2014-08-22 17:43 UTC (permalink / raw)
  To: Grant Likely, Rob Herring; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA

The of_n_size_cells() routine only does a read-only operation on the device tree
passed in, so add the const keyword to that argument so that of_n_size_cells()
can be called with read-only data without casting.

Signed-off-by: Geoff Levand <geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
---
The following changes since commit 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9:

  Linux 3.17-rc1 (2014-08-16 10:40:26 -0600)

are available in the git repository at:

  git://git.linaro.org/people/geoff.levand/linux-kexec.git for-of

for you to fetch changes up to e7667576c053daedba1da0b14d4476bc25a86a11:

  of: Fix constantness of of_n_size_cells (2014-08-22 10:33:59 -0700)

----------------------------------------------------------------
Geoff Levand (1):
      of: Fix constantness of of_n_size_cells
 drivers/of/base.c  | 4 ++--
 include/linux/of.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d8574ad..f773679 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -53,7 +53,7 @@ DEFINE_MUTEX(of_mutex);
  */
 DEFINE_RAW_SPINLOCK(devtree_lock);
 
-int of_n_addr_cells(struct device_node *np)
+int of_n_addr_cells(const struct device_node *np)
 {
 	const __be32 *ip;
 
@@ -69,7 +69,7 @@ int of_n_addr_cells(struct device_node *np)
 }
 EXPORT_SYMBOL(of_n_addr_cells);
 
-int of_n_size_cells(struct device_node *np)
+int of_n_size_cells(const struct device_node *np)
 {
 	const __be32 *ip;
 
diff --git a/include/linux/of.h b/include/linux/of.h
index 6c4363b..6eebcf6 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -285,8 +285,8 @@ extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
 #define for_each_property_of_node(dn, pp) \
 	for (pp = dn->properties; pp != NULL; pp = pp->next)
 
-extern int of_n_addr_cells(struct device_node *np);
-extern int of_n_size_cells(struct device_node *np);
+extern int of_n_addr_cells(const struct device_node *np);
+extern int of_n_size_cells(const struct device_node *np);
 extern const struct of_device_id *of_match_node(
 	const struct of_device_id *matches, const struct device_node *node);
 extern int of_modalias_node(struct device_node *node, char *modalias, int len);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] of: Fix constantness of of_n_size_cells
       [not found] ` <cover.1408729200.git.geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2014-08-27 10:28   ` Grant Likely
       [not found]     ` <20140827102827.50E15C409CB-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Grant Likely @ 2014-08-27 10:28 UTC (permalink / raw)
  To: Geoff Levand, Rob Herring; +Cc: devicetree-u79uwXL29TY76Z2rM5mHXA

On Fri, 22 Aug 2014 17:43:36 +0000, Geoff Levand <geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> wrote:
> The of_n_size_cells() routine only does a read-only operation on the device tree
> passed in, so add the const keyword to that argument so that of_n_size_cells()
> can be called with read-only data without casting.
> 
> Signed-off-by: Geoff Levand <geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>

What is the code that exposed this problem?

g.

> ---
> The following changes since commit 7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9:
> 
>   Linux 3.17-rc1 (2014-08-16 10:40:26 -0600)
> 
> are available in the git repository at:
> 
>   git://git.linaro.org/people/geoff.levand/linux-kexec.git for-of
> 
> for you to fetch changes up to e7667576c053daedba1da0b14d4476bc25a86a11:
> 
>   of: Fix constantness of of_n_size_cells (2014-08-22 10:33:59 -0700)
> 
> ----------------------------------------------------------------
> Geoff Levand (1):
>       of: Fix constantness of of_n_size_cells
>  drivers/of/base.c  | 4 ++--
>  include/linux/of.h | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index d8574ad..f773679 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -53,7 +53,7 @@ DEFINE_MUTEX(of_mutex);
>   */
>  DEFINE_RAW_SPINLOCK(devtree_lock);
>  
> -int of_n_addr_cells(struct device_node *np)
> +int of_n_addr_cells(const struct device_node *np)
>  {
>  	const __be32 *ip;
>  
> @@ -69,7 +69,7 @@ int of_n_addr_cells(struct device_node *np)
>  }
>  EXPORT_SYMBOL(of_n_addr_cells);
>  
> -int of_n_size_cells(struct device_node *np)
> +int of_n_size_cells(const struct device_node *np)
>  {
>  	const __be32 *ip;
>  
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 6c4363b..6eebcf6 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -285,8 +285,8 @@ extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
>  #define for_each_property_of_node(dn, pp) \
>  	for (pp = dn->properties; pp != NULL; pp = pp->next)
>  
> -extern int of_n_addr_cells(struct device_node *np);
> -extern int of_n_size_cells(struct device_node *np);
> +extern int of_n_addr_cells(const struct device_node *np);
> +extern int of_n_size_cells(const struct device_node *np);
>  extern const struct of_device_id *of_match_node(
>  	const struct of_device_id *matches, const struct device_node *node);
>  extern int of_modalias_node(struct device_node *node, char *modalias, int len);
> -- 
> 1.9.1
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] of: Fix constantness of of_n_size_cells
       [not found]     ` <20140827102827.50E15C409CB-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
@ 2014-08-29 19:26       ` Geoff Levand
  0 siblings, 0 replies; 3+ messages in thread
From: Geoff Levand @ 2014-08-29 19:26 UTC (permalink / raw)
  To: Grant Likely; +Cc: Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA

Hi Grant,

On Wed, 2014-08-27 at 11:28 +0100, Grant Likely wrote:
> On Fri, 22 Aug 2014 17:43:36 +0000, Geoff Levand <geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org> wrote:
> > The of_n_size_cells() routine only does a read-only operation on the device tree
> > passed in, so add the const keyword to that argument so that of_n_size_cells()
> > can be called with read-only data without casting.
> > 
> > Signed-off-by: Geoff Levand <geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
> 
> What is the code that exposed this problem?

For the arm64 kexec support and the arm64 spin-table hot-plug support I
am working on I need to read the cpu hardware id from a device tree.  I
don't need to modify the device tree, just get property values, so in
that code I have it in a pointer to a const.  I can cast off that const
when I do the call to of_n_size_cells() if you don't think it worthwhile
to make this change.  Here's the code:

+	p->hwid = of_read_number(cell, of_n_addr_cells(dn))
+		& MPIDR_HWID_BITMASK;

-Geoff

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-29 19:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22 17:43 [PATCH] of: Fix constantness of of_n_size_cells Geoff Levand
     [not found] ` <cover.1408729200.git.geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2014-08-27 10:28   ` Grant Likely
     [not found]     ` <20140827102827.50E15C409CB-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-08-29 19:26       ` Geoff Levand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.