diff options
author | Michael Neuling <mikey@neuling.org> | 2012-11-06 09:49:15 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-01-09 22:43:46 -0500 |
commit | 2f1d4ea7bcd96d3796eba4087388bdb37322ee7a (patch) | |
tree | e0df566a4fa9aaa085bfb8c4a0a35b80adf5f813 /arch | |
parent | 1e18c17adf32b86474fd903071b0181de9334bd4 (diff) |
powerpc/pseries: Allow firmware features to match partial strings
This allows firmware_features_table names to add a '*' at the end so that only
partial strings are matched.
When a '*' is added, only upto the '*' is matched when setting firmware feature
bits.
This is useful for the matching best energy feature.
Signed-off-by: Michael Neuling <mikey@neuling.org>
cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
cc: Linux PPC dev <linuxppc-dev@ozlabs.org>
Reviewed-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/pseries/firmware.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c index 7b56118f531c..55b98c3dc47a 100644 --- a/arch/powerpc/platforms/pseries/firmware.c +++ b/arch/powerpc/platforms/pseries/firmware.c | |||
@@ -33,6 +33,11 @@ typedef struct { | |||
33 | char * name; | 33 | char * name; |
34 | } firmware_feature_t; | 34 | } firmware_feature_t; |
35 | 35 | ||
36 | /* | ||
37 | * The names in this table match names in rtas/ibm,hypertas-functions. If the | ||
38 | * entry ends in a '*', only upto the '*' is matched. Otherwise the entire | ||
39 | * string must match. | ||
40 | */ | ||
36 | static __initdata firmware_feature_t | 41 | static __initdata firmware_feature_t |
37 | firmware_features_table[FIRMWARE_MAX_FEATURES] = { | 42 | firmware_features_table[FIRMWARE_MAX_FEATURES] = { |
38 | {FW_FEATURE_PFT, "hcall-pft"}, | 43 | {FW_FEATURE_PFT, "hcall-pft"}, |
@@ -72,9 +77,20 @@ void __init fw_feature_init(const char *hypertas, unsigned long len) | |||
72 | 77 | ||
73 | for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) { | 78 | for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) { |
74 | for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) { | 79 | for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) { |
80 | const char *name = firmware_features_table[i].name; | ||
81 | size_t size; | ||
75 | /* check value against table of strings */ | 82 | /* check value against table of strings */ |
76 | if (!firmware_features_table[i].name || | 83 | if (!name) |
77 | strcmp(firmware_features_table[i].name, s)) | 84 | continue; |
85 | /* | ||
86 | * If there is a '*' at the end of name, only check | ||
87 | * upto there | ||
88 | */ | ||
89 | size = strlen(name); | ||
90 | if (size && name[size - 1] == '*') { | ||
91 | if (strncmp(name, s, size - 1)) | ||
92 | continue; | ||
93 | } else if (strcmp(name, s)) | ||
78 | continue; | 94 | continue; |
79 | 95 | ||
80 | /* we have a match */ | 96 | /* we have a match */ |