LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc/pseries: Allow firmware features to match partial strings
@ 2012-11-07  0:49 Michael Neuling
  2012-11-07  0:49 ` [PATCH 2/2] powerpc/pseries: Cleanup best_energy_hcall detection Michael Neuling
  2012-11-07  5:30 ` [PATCH 1/2] powerpc/pseries: Allow firmware features to match partial strings Stephen Rothwell
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Neuling @ 2012-11-07  0:49 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Linux PPC dev, Michael Neuling

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>
---
 arch/powerpc/platforms/pseries/firmware.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index 0b0eff0..448c053 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -33,6 +33,11 @@ typedef struct {
     char * name;
 } firmware_feature_t;
 
+/*
+ * The names in this table match names in rtas/ibm,hypertas-functions.  If the
+ * entry ends in a '*', only upto the '*' is matched.  Otherwise the entire
+ * string must match.
+ */
 static __initdata firmware_feature_t
 firmware_features_table[FIRMWARE_MAX_FEATURES] = {
 	{FW_FEATURE_PFT,		"hcall-pft"},
@@ -71,9 +76,20 @@ void __init fw_feature_init(const char *hypertas, unsigned long len)
 
 	for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
 		for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) {
+			const char *name = firmware_features_table[i].name;
+			size_t size;
 			/* check value against table of strings */
-			if (!firmware_features_table[i].name ||
-			    strcmp(firmware_features_table[i].name, s))
+			if (!name)
+				continue;
+			/*
+			 * If there is a '*' at the end of name, only check
+			 * upto there
+			 */
+			size = strlen(name);
+			if (size && name[size - 1] == '*') {
+				if (strncmp(name, s, size - 1))
+					continue;
+			} else if (strcmp(name, s))
 				continue;
 
 			/* we have a match */
-- 
1.7.9.5

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

end of thread, other threads:[~2012-11-07  5:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-07  0:49 [PATCH 1/2] powerpc/pseries: Allow firmware features to match partial strings Michael Neuling
2012-11-07  0:49 ` [PATCH 2/2] powerpc/pseries: Cleanup best_energy_hcall detection Michael Neuling
2012-11-07  5:30 ` [PATCH 1/2] powerpc/pseries: Allow firmware features to match partial strings Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox