From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77574C2D0A3 for ; Thu, 12 Nov 2020 07:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11C75221FB for ; Thu, 12 Nov 2020 07:51:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="g+ARMDQE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbgKLHv0 (ORCPT ); Thu, 12 Nov 2020 02:51:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:41192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbgKLHvZ (ORCPT ); Thu, 12 Nov 2020 02:51:25 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A374721D40; Thu, 12 Nov 2020 07:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605167485; bh=H++voLjw8gNQ+Dq+Pow/iwcpS4sbWJ++caecK3Ys/3s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g+ARMDQEcHkGj5PIN204gzzNtScCtTqBgH2jXcRHbEmjDx1BCZRQowhKbjrY6gSlJ tLfnLOx11RxPTzK6hNvzqiRdvtTha0029SEYqgCYpUUXR32C9OOpy7jO9EzTlu6Edr 1a99BcmAONXdbuKTK1gjcvgaxSXLj1SySQ7nLDqo= Date: Thu, 12 Nov 2020 08:52:23 +0100 From: Greg KH To: Junyong Sun Cc: arnd@arndb.de, sunjunyong@xiaomi.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ttyprintk: optimize tpk_close flush code Message-ID: References: <1604469744-8708-1-git-send-email-sunjunyong@xiaomi.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1604469744-8708-1-git-send-email-sunjunyong@xiaomi.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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