of: Fix constantness of of_n_size_cells
PATCH 1/1 of: Fix constantness of of_n_size_cells
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.
---
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(-)
drivers/of/base.c +2 -2
@@ -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;
include/linux/of.h +2 -2
@@ -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);
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): cover.1408729200.git.geoff-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org
Quoted 5 lines · Geoff Levand
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 thatof_n_size_cells()can be called with read-only data without casting.Signed-off-by Geoff Levand <[email protected]>
What is the code that exposed this problem?
g.
Quoted 60 lines
---
The following changes since commit7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9: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.gitfor-offor 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 ofof_n_size_cellsdrivers/of/base.c | 4 ++-- include/linux/of.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/of/base.c +2
-2@@ -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;include/linux/of.h +2
-2@@ -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);Signature · 1 line
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20140827102827.50E15C409CB-WNowdnHR2B42iJbIjFUEsiwD8/[email protected]
Hi Grant,
Quoted 8 lines · Grant Likely
Quoted 5 lines · Geoff Levand
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 thatof_n_size_cells()can be called with read-only data without casting.Signed-off-by Geoff Levand <[email protected]>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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html