aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-08-07 21:46:36 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-08-07 21:46:36 -0400
commit46bcea7751efc867ae4b073c99ad1d137a475bc0 (patch)
tree6600d52d5131d2ed1eb95640aa3604aecbcbc4af
parent4a2a4df7b6db25df8f3d5cc6dd0b096119359d92 (diff)
[SPARC]: Centralize find_in_proplist() instead of duplicating N times.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc/kernel/prom.c15
-rw-r--r--arch/sparc64/kernel/mdesc.c24
-rw-r--r--arch/sparc64/kernel/prom.c15
-rw-r--r--arch/sparc64/kernel/vio.c19
-rw-r--r--include/asm-sparc/prom.h1
-rw-r--r--include/asm-sparc64/prom.h1
6 files changed, 39 insertions, 36 deletions
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index 39fbd3c8ab0b..cd4fb79aa3a8 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -102,6 +102,21 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
102} 102}
103EXPORT_SYMBOL(of_set_property); 103EXPORT_SYMBOL(of_set_property);
104 104
105int of_find_in_proplist(const char *list, const char *match, int len)
106{
107 while (len > 0) {
108 int l;
109
110 if (!strcmp(list, match))
111 return 1;
112 l = strlen(list) + 1;
113 list += l;
114 len -= l;
115 }
116 return 0;
117}
118EXPORT_SYMBOL(of_find_in_proplist);
119
105static unsigned int prom_early_allocated; 120static unsigned int prom_early_allocated;
106 121
107static void * __init prom_early_alloc(unsigned long size) 122static void * __init prom_early_alloc(unsigned long size)
diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c
index cce4d0ddf5d5..95059c2ec414 100644
--- a/arch/sparc64/kernel/mdesc.c
+++ b/arch/sparc64/kernel/mdesc.c
@@ -568,20 +568,6 @@ static void __init report_platform_properties(void)
568 mdesc_release(hp); 568 mdesc_release(hp);
569} 569}
570 570
571static int inline find_in_proplist(const char *list, const char *match, int len)
572{
573 while (len > 0) {
574 int l;
575
576 if (!strcmp(list, match))
577 return 1;
578 l = strlen(list) + 1;
579 list += l;
580 len -= l;
581 }
582 return 0;
583}
584
585static void __devinit fill_in_one_cache(cpuinfo_sparc *c, 571static void __devinit fill_in_one_cache(cpuinfo_sparc *c,
586 struct mdesc_handle *hp, 572 struct mdesc_handle *hp,
587 u64 mp) 573 u64 mp)
@@ -596,10 +582,10 @@ static void __devinit fill_in_one_cache(cpuinfo_sparc *c,
596 582
597 switch (*level) { 583 switch (*level) {
598 case 1: 584 case 1:
599 if (find_in_proplist(type, "instn", type_len)) { 585 if (of_find_in_proplist(type, "instn", type_len)) {
600 c->icache_size = *size; 586 c->icache_size = *size;
601 c->icache_line_size = *line_size; 587 c->icache_line_size = *line_size;
602 } else if (find_in_proplist(type, "data", type_len)) { 588 } else if (of_find_in_proplist(type, "data", type_len)) {
603 c->dcache_size = *size; 589 c->dcache_size = *size;
604 c->dcache_line_size = *line_size; 590 c->dcache_line_size = *line_size;
605 } 591 }
@@ -677,7 +663,7 @@ static void __devinit set_core_ids(struct mdesc_handle *hp)
677 continue; 663 continue;
678 664
679 type = mdesc_get_property(hp, mp, "type", &len); 665 type = mdesc_get_property(hp, mp, "type", &len);
680 if (!find_in_proplist(type, "instn", len)) 666 if (!of_find_in_proplist(type, "instn", len))
681 continue; 667 continue;
682 668
683 mark_core_ids(hp, mp, idx); 669 mark_core_ids(hp, mp, idx);
@@ -718,8 +704,8 @@ static void __devinit __set_proc_ids(struct mdesc_handle *hp,
718 int len; 704 int len;
719 705
720 type = mdesc_get_property(hp, mp, "type", &len); 706 type = mdesc_get_property(hp, mp, "type", &len);
721 if (!find_in_proplist(type, "int", len) && 707 if (!of_find_in_proplist(type, "int", len) &&
722 !find_in_proplist(type, "integer", len)) 708 !of_find_in_proplist(type, "integer", len))
723 continue; 709 continue;
724 710
725 mark_proc_ids(hp, mp, idx); 711 mark_proc_ids(hp, mp, idx);
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index f4e0a9ad9be3..d1a78c976cef 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -107,6 +107,21 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
107} 107}
108EXPORT_SYMBOL(of_set_property); 108EXPORT_SYMBOL(of_set_property);
109 109
110int of_find_in_proplist(const char *list, const char *match, int len)
111{
112 while (len > 0) {
113 int l;
114
115 if (!strcmp(list, match))
116 return 1;
117 l = strlen(list) + 1;
118 list += l;
119 len -= l;
120 }
121 return 0;
122}
123EXPORT_SYMBOL(of_find_in_proplist);
124
110static unsigned int prom_early_allocated; 125static unsigned int prom_early_allocated;
111 126
112static void * __init prom_early_alloc(unsigned long size) 127static void * __init prom_early_alloc(unsigned long size)
diff --git a/arch/sparc64/kernel/vio.c b/arch/sparc64/kernel/vio.c
index 3685daf5157f..1550ac5673da 100644
--- a/arch/sparc64/kernel/vio.c
+++ b/arch/sparc64/kernel/vio.c
@@ -16,21 +16,6 @@
16#include <asm/mdesc.h> 16#include <asm/mdesc.h>
17#include <asm/vio.h> 17#include <asm/vio.h>
18 18
19static inline int find_in_proplist(const char *list, const char *match,
20 int len)
21{
22 while (len > 0) {
23 int l;
24
25 if (!strcmp(list, match))
26 return 1;
27 l = strlen(list) + 1;
28 list += l;
29 len -= l;
30 }
31 return 0;
32}
33
34static const struct vio_device_id *vio_match_device( 19static const struct vio_device_id *vio_match_device(
35 const struct vio_device_id *matches, 20 const struct vio_device_id *matches,
36 const struct vio_dev *dev) 21 const struct vio_dev *dev)
@@ -49,7 +34,7 @@ static const struct vio_device_id *vio_match_device(
49 34
50 if (matches->compat[0]) { 35 if (matches->compat[0]) {
51 match &= len && 36 match &= len &&
52 find_in_proplist(compat, matches->compat, len); 37 of_find_in_proplist(compat, matches->compat, len);
53 } 38 }
54 if (match) 39 if (match)
55 return matches; 40 return matches;
@@ -406,7 +391,7 @@ static int __init vio_init(void)
406 "property\n"); 391 "property\n");
407 goto out_release; 392 goto out_release;
408 } 393 }
409 if (!find_in_proplist(compat, channel_devices_compat, len)) { 394 if (!of_find_in_proplist(compat, channel_devices_compat, len)) {
410 printk(KERN_ERR "VIO: Channel devices node lacks (%s) " 395 printk(KERN_ERR "VIO: Channel devices node lacks (%s) "
411 "compat entry.\n", channel_devices_compat); 396 "compat entry.\n", channel_devices_compat);
412 goto out_release; 397 goto out_release;
diff --git a/include/asm-sparc/prom.h b/include/asm-sparc/prom.h
index 350676c589f9..71f2a1998324 100644
--- a/include/asm-sparc/prom.h
+++ b/include/asm-sparc/prom.h
@@ -67,6 +67,7 @@ extern int of_set_property(struct device_node *node, const char *name, void *val
67extern int of_getintprop_default(struct device_node *np, 67extern int of_getintprop_default(struct device_node *np,
68 const char *name, 68 const char *name,
69 int def); 69 int def);
70extern int of_find_in_proplist(const char *list, const char *match, int len);
70 71
71extern void prom_build_devicetree(void); 72extern void prom_build_devicetree(void);
72 73
diff --git a/include/asm-sparc64/prom.h b/include/asm-sparc64/prom.h
index 31dcb92fbae0..07843f9f05df 100644
--- a/include/asm-sparc64/prom.h
+++ b/include/asm-sparc64/prom.h
@@ -76,6 +76,7 @@ extern int of_set_property(struct device_node *node, const char *name, void *val
76extern int of_getintprop_default(struct device_node *np, 76extern int of_getintprop_default(struct device_node *np,
77 const char *name, 77 const char *name,
78 int def); 78 int def);
79extern int of_find_in_proplist(const char *list, const char *match, int len);
79 80
80extern void prom_build_devicetree(void); 81extern void prom_build_devicetree(void);
81 82