linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: sm750fb: skip unnecessary comparisons
@ 2017-07-03  1:26 Lynn Lei
  2017-07-03  6:19 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Lynn Lei @ 2017-07-03  1:26 UTC (permalink / raw)
  To: sudipm.mukherjee; +Cc: teddy.wang, linux-fbdev, linux-kernel, devel

introduced early checks to skip unnecessary comparisons when flags set.

Signed-off-by: Lynn Lei <lynnl.wit@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 386d4adcd91d..9e57a2d32465 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -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);
-- 
2.13.2


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

* Re: [PATCH] staging: sm750fb: skip unnecessary comparisons
  2017-07-03  1:26 [PATCH] staging: sm750fb: skip unnecessary comparisons Lynn Lei
@ 2017-07-03  6:19 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2017-07-03  6:19 UTC (permalink / raw)
  To: Lynn Lei; +Cc: sudipm.mukherjee, devel, linux-fbdev, teddy.wang, linux-kernel

On Mon, Jul 03, 2017 at 09:26:47AM +0800, Lynn Lei wrote:
> introduced early checks to skip unnecessary comparisons when flags set.

Why?

> 
> Signed-off-by: Lynn Lei <lynnl.wit@gmail.com>
> ---
>  drivers/staging/sm750fb/sm750.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index 386d4adcd91d..9e57a2d32465 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -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?

> +		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

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

end of thread, other threads:[~2017-07-03  6:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-03  1:26 [PATCH] staging: sm750fb: skip unnecessary comparisons Lynn Lei
2017-07-03  6:19 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).