staging: sm750fb: skip unnecessary comparisons
PATCH 1/1 staging: sm750fb: skip unnecessary comparisons
introduced early checks to skip unnecessary comparisons when flags set.
Signed-off-by Lynn Lei <[email protected]>
--- drivers/staging/sm750fb/sm750.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/sm750.c +8 -3
@@ -1171,11 +1171,16 @@ static int __init lynxfb_setup(char *options)*/ while ((opt =strsep (&options,":" )) !=NULL ) {/* options that mean for any lynx chips are configured here */ -if (!strncmp (opt,"noaccel" ,strlen ("noaccel" ))) { + +/* +* NOTE: the length of options is hard-coded +* if any of those options changed please update its length +*/ +if (!g_noaccel && !strncmp (opt,"noaccel" ,7 )) { g_noaccel =1 ; - }else if (!strncmp (opt,"nomtrr" ,strlen ("nomtrr" ))) { + }else if (!g_nomtrr && !strncmp (opt,"nomtrr" ,6 )) { g_nomtrr =1 ; - }else if (!strncmp (opt,"dual" ,strlen ("dual" ))) { + }else if (!g_dualview && !strncmp (opt,"dual" ,4 )) { g_dualview =1 ; }else {strcat (tmp, opt);
Signature · 1 line
2.13.2
Greg KH
maintainerQuoted 1 line · Lynn Lei
introduced early checks to skip unnecessary comparisons when flags set.
Why?
Quoted 11 lines
Signed-off-by Lynn Lei <[email protected]>--- drivers/staging/sm750fb/sm750.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/staging/sm750fb/sm750.c +0
-0
drivers/staging/sm750fb/sm750.c static int __init lynxfb_setup(char *options) · line 1178
Quoted 9 lines
drivers/staging/sm750fb/sm750.c +5
-1@@ -1171,11 +1171,16 @@ static int __init lynxfb_setup(char *options)*/ while ((opt =strsep (&options,":" )) !=NULL ) {/* options that mean for any lynx chips are configured here */ -if (!strncmp (opt,"noaccel" ,strlen ("noaccel" ))) { + +/* +* NOTE: the length of options is hard-coded +* if any of those options changed please update its length +*/
That's not good, why require this? What is wrong with the original code here? It doesn't have that type of restriction, right?
drivers/staging/sm750fb/sm750.c static int __init lynxfb_setup(char *options) · line 1181
Quoted 4 lines
drivers/staging/sm750fb/sm750.c +2
-1+if (!g_noaccel && !strncmp (opt,"noaccel" ,7 )) { g_noaccel =1 ; - }else if (!strncmp (opt,"nomtrr" ,strlen ("nomtrr" ))) { + }else if (!g_nomtrr && !strncmp (opt,"nomtrr" ,6 )) {
I don't see the benefit of this change at all, what am I missing?
thanks,
greg k-h