ttyprintk: optimize tpk_close flush code
PATCH 1/1 ttyprintk: optimize tpk_close flush code
tpk_printk(NULL,0) do nothing but call tpk_flush to flush buffer, so why don't use tpk_flush diretcly? this is a small optimization.
--- drivers/char/ttyprintk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/ttyprintk.c +1 -1
@@ -104,7 +104,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&tpkp->spinlock, flags);/* flush tpk_printk buffer */ -tpk_printk (NULL ,0 ); +tpk_flush ();spin_unlock_irqrestore (&tpkp->spinlock, flags);tty_port_close (&tpkp->port, tty, filp);
Signature · 1 line
2.7.4
Greg KH
maintainerQuoted 14 lines · Junyong Sun
tpk_printk(NULL,0)do nothing but calltpk_flushto flush buffer, so why don't usetpk_flushdiretcly? this is a small optimization.Signed-off-by Junyong Sun <[email protected]>--- drivers/char/ttyprintk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/ttyprintk.c +0
-0
drivers/char/ttyprintk.c static void tpk_close(struct tty_struct *tty, struct file *filp) · line 107
Quoted 5 lines
drivers/char/ttyprintk.c +1
-1@@ -104,7 +104,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&tpkp->spinlock, flags);/* flush tpk_printk buffer */ -tpk_printk (NULL ,0 ); +tpk_flush ();
If you do this, then please remove the logic in tpk_flush() that handles NULL as now that logic will not be needed at all, right?
Also the comment here wouldn't be needed as the code obviously does that based on the function call being made :)
thanks,
greg k-h
Hi Greg:
It have no logic that handles NULL in tpk_flush() but tpk_printk(). Do you mean that if i understand correctly?!I think we should not remove the logic that handles NULL in tpk_printk() as we don't know if the buf from parent caller is null or not.But we transfer a null buf to tpk_printk()
for previous version of tpk_close, i think it's redundant.
The comment is a hitory tip for other guys to understand.I suggest to keep it as before if you like.
thanks
JY
Quoted 30 lines · Greg KH
Quoted 14 lines · Junyong Sun
tpk_printk(NULL,0)do nothing but calltpk_flushto flush buffer, so why don't usetpk_flushdiretcly? this is a small optimization.Signed-off-by Junyong Sun <[email protected]>--- drivers/char/ttyprintk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/ttyprintk.c +0
-0drivers/char/ttyprintk.c static void tpk_close(struct tty_struct *tty, struct file *filp) · line 107
Quoted 5 lines
drivers/char/ttyprintk.c +1
-1@@ -104,7 +104,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)spin_lock_irqsave (&tpkp->spinlock, flags);/* flush tpk_printk buffer */ -tpk_printk (NULL ,0 ); +tpk_flush ();If you do this, then please remove the logic in
tpk_flush()that handles NULL as now that logic will not be needed at all, right?Also the comment here wouldn't be needed as the code obviously does that based on the function call being made :)
thanks,
greg k-h
Greg KH
maintainerA: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
Quoted 2 lines · sunjunyong
Hi Greg:
It have no logic that handles NULL intpk_flush()buttpk_printk().
Sorry, yes, that is what I mean.
Quoted 3 lines
Do you mean that if i understand correctly?!I think we should not remove the logic that handles NULL in
tpk_printk()as we don't know if the buf from parent caller is null or not.
Yes you do, you control that buffer right? This is a static function, you know what is happening here.
Quoted 5 lines
But we transfer a null buf to
tpk_printk()
for previous version oftpk_close, i think it's redundant.The comment is a hitory tip for other guys to understand.I suggest to keep it as before if you like.
The call to flush makes it obvious, no need to keep it. And we have git history for people to look at if they are curious about past versions.
thanks,
greg k-h
Hi greg:
Quoted 2 lines
The call to flush makes it obvious, no need to keep it. And we have git history for people to look at if they are curious about past versions.
you are right. I would remove it in next version.
Any other suggestions ?
thanks!
JY.