Skip to contentSkip to conversation

ttyprintk: optimize tpk_close flush code

PATCH In review Junyong Sun 2 participants 3 messages Nov 17, 2020 – Nov 28, 2020 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
changes in v2:
- rm the flush comment as tpk_flush makes it obvious.
---

---
 drivers/char/ttyprintk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/ttyprintk.c +1 -2
index 6a0059e..1f82742 100644
@@ -103,8 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)
 	unsigned long flags;
 
 	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
maintainer
#1 lore raw
Quoted 18 lines · Junyong Sun

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.

---
changes in v2:
- rm the flush comment as tpk_flush makes it obvious.
---

---
 drivers/char/ttyprintk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/ttyprintk.c +0 -0
index 6a0059e..1f82742 100644

drivers/char/ttyprintk.c static void tpk_close(struct tty_struct *tty, struct file *filp) · line 107

Quoted 7 lines
drivers/char/ttyprintk.c +1 -2
@@ -103,8 +103,7 @@ static void tpk_close(struct tty_struct *tty, struct file *filp)
 	unsigned long flags;
 
 	spin_lock_irqsave(&tpkp->spinlock, flags);
-	/* flush tpk_printk buffer */
-	tpk_printk(NULL, 0);
+	tpk_flush();
 	spin_unlock_irqrestore(&tpkp->spinlock, flags);

Why did you not make the change to tpk_printk() as well that I asked you to?

It is a static function, you control the callers, so the extra "is this NULL, if so flush" logic makes no sense to keep around anymore, right?

thanks,

greg k-h

author
#2 lore raw

Hi Greg:

Sorry for the late reply.

Quoted 5 lines

Why did you not make the change to tpk_printk() as well that I asked you to?

It is a static function, you control the callers, so the extra "is this NULL, if so flush" logic makes no sense to keep around anymore, right?

tpk_printk have logic to judge whether the input parameter is NULL.But for below removed line, we already have known the input parameter is null, so we don't need call logic of judge NULL, just call tpk_flush to flush is enough. This is just a little optimization.
----------------------------
- tpk_printk(NULL, 0);
----------------------------

Brs.
Junyong