From: Michael Neuling Date: Tue, 6 Nov 2012 14:49:15 +0000 (+0000) Subject: powerpc/pseries: Allow firmware features to match partial strings X-Git-Tag: firefly_0821_release~3680^2~1053^2~99 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2f1d4ea7bcd96d3796eba4087388bdb37322ee7a;p=firefly-linux-kernel-4.4.55.git 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 cc: Vaidyanathan Srinivasan cc: Linux PPC dev Reviewed-by: Stephen Rothwell Signed-off-by: Benjamin Herrenschmidt --- 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 { 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"}, @@ -72,9 +77,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 */