aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-08-20 00:56:35 -0400
committerDavid S. Miller <davem@davemloft.net>2008-08-24 23:33:55 -0400
commit2481d76615d5e15340ccfb0243fe8779766dfc6e (patch)
tree2d047756426224d741388b4c557151f9a7cb8335 /arch/sparc
parent072bd413b88c17509c7aa7dbc398ab8bade633b3 (diff)
sparc: Add mutex for set property calls.
On some platforms, the I2C controller is shared between the OS and OBP. OBP uses this I2C controller to access the EEPROM, and thus is programmed when the kernel calls prom_setprop(). Wrap such calls with the new of_set_property_mutex. Relevant I2C bus drivers can grab this mutex around top-level I2C operations to provide the proper protection. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/include/asm/prom.h2
-rw-r--r--arch/sparc/kernel/prom.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index fd55522481cd..b5efc4d85234 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -18,6 +18,7 @@
18 */ 18 */
19#include <linux/types.h> 19#include <linux/types.h>
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/mutex.h>
21#include <asm/atomic.h> 22#include <asm/atomic.h>
22 23
23#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 24#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
@@ -73,6 +74,7 @@ struct of_irq_controller {
73 74
74extern struct device_node *of_find_node_by_cpuid(int cpuid); 75extern struct device_node *of_find_node_by_cpuid(int cpuid);
75extern int of_set_property(struct device_node *node, const char *name, void *val, int len); 76extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
77extern struct mutex of_set_property_mutex;
76extern int of_getintprop_default(struct device_node *np, 78extern int of_getintprop_default(struct device_node *np,
77 const char *name, 79 const char *name,
78 int def); 80 int def);
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index cd4fb79aa3a8..43e862406822 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -54,6 +54,9 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
54} 54}
55EXPORT_SYMBOL(of_getintprop_default); 55EXPORT_SYMBOL(of_getintprop_default);
56 56
57DEFINE_MUTEX(of_set_property_mutex);
58EXPORT_SYMBOL(of_set_property_mutex);
59
57int of_set_property(struct device_node *dp, const char *name, void *val, int len) 60int of_set_property(struct device_node *dp, const char *name, void *val, int len)
58{ 61{
59 struct property **prevp; 62 struct property **prevp;
@@ -77,7 +80,10 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
77 void *old_val = prop->value; 80 void *old_val = prop->value;
78 int ret; 81 int ret;
79 82
83 mutex_lock(&of_set_property_mutex);
80 ret = prom_setprop(dp->node, (char *) name, val, len); 84 ret = prom_setprop(dp->node, (char *) name, val, len);
85 mutex_unlock(&of_set_property_mutex);
86
81 err = -EINVAL; 87 err = -EINVAL;
82 if (ret >= 0) { 88 if (ret >= 0) {
83 prop->value = new_val; 89 prop->value = new_val;