lkml.org 
[lkml]   [2020]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ttyprintk: optimize tpk_close flush code
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
On Thu, Nov 12, 2020 at 08:52:23AM +0100, Greg KH wrote:
> On Wed, Nov 04, 2020 at 02:02:24PM +0800, Junyong Sun wrote:
> > 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.
> >
> > Signed-off-by: Junyong Sun <sunjunyong@xiaomi.com>
> > ---
> > drivers/char/ttyprintk.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
> > index 6a0059e..2ce78b3 100644
> > --- a/drivers/char/ttyprintk.c
> > +++ b/drivers/char/ttyprintk.c
> > @@ -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

\
 
 \ /
  Last update: 2020-11-12 14:42    [W:0.063 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site