Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4300817pxj; Wed, 12 May 2021 02:30:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzN2TMiP83wbsbxxTdhHqRdDPzC2c4GtNAJAIP7EAjej5wJhZMKCSYH3HCFtoHowOgI6ty X-Received: by 2002:a17:907:3e06:: with SMTP id hp6mr36368171ejc.273.1620811852589; Wed, 12 May 2021 02:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620811852; cv=none; d=google.com; s=arc-20160816; b=P+wGv9cUGJEct9HouZ3+o8pMVHOXS6vPYP7qa7jbniGuRPF5LWfH3YejmlzYcFpAVh kLirg5FXYrBBfLWP2G+dv5eB9qbtkieWLD5dMceS55jmUf+pfcRJzODJAW0vY8Jl7g1K nQh7THpc31A94m+Zpsiw6Atm3SyJoOnSSmfEpR0Gs+8PdZ6womXMDuFG+NCjnv3CJrUq XNOopoqhvS895/Zh/ki3/RS0gfjY1y0pN7APaO4+V/ucEJ6PuiCQy+zNOo2cLD9kxpL1 onPXFNjL3L8bfH/V7ZyIvU1vuwfW8bHV9EktFK6IFSylPUjomIrkX1HQXUP5zLjdDSgl uFzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=9vrOAfN2rt3ZNK5sbaiymNIYlCGNrqeXFTn8nl2TyHs=; b=HxYI+JqQf3KtEmfzXDzPZ6PxZi8XZt8hg2qdzW6OgNuRCSdyfcnZ18kXgNUyzIN+CT 889ZMXzsNf4ucViTa73zBWDZdaPaX8k1diJRF4RAShFZsC1ELJUhaBKQixm1+BJt4s4p Y5hnbxtBhHezsfRB13xZyYfQk4LDIohNQ+1VuqlghHIJ56zyY3bTSwISlw5ah0SN4aUT 0p9QttS7srtdIZIDvxXNQNv6/863TLA1xxZeXzrsk3kFbHl5EPc5sdyc6s0XqecATKCd drQf2OheInWK6t8Pvbp/qAJkfCyYNvjUYK5+9zJKN7yc0aLIG3tBVukUGIEq8ywXPm/2 IxbQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r14si17524291edb.259.2021.05.12.02.30.29; Wed, 12 May 2021 02:30:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbhELJao (ORCPT + 99 others); Wed, 12 May 2021 05:30:44 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:2459 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhELJam (ORCPT ); Wed, 12 May 2021 05:30:42 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Fg8Z21s0szBtSv; Wed, 12 May 2021 17:26:50 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Wed, 12 May 2021 17:29:24 +0800 From: Xiaofei Tan To: , CC: , , Xiaofei Tan Subject: [PATCH 03/17] tty: tty_buffer: Add a blank line after declarations Date: Wed, 12 May 2021 17:26:11 +0800 Message-ID: <1620811585-18582-4-git-send-email-tanxiaofei@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1620811585-18582-1-git-send-email-tanxiaofei@huawei.com> References: <1620811585-18582-1-git-send-email-tanxiaofei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a blank line after declarations, reported by checkpatch.pl. Signed-off-by: Xiaofei Tan --- drivers/tty/tty_buffer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 9733469..5509b5d 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c @@ -91,6 +91,7 @@ EXPORT_SYMBOL_GPL(tty_buffer_unlock_exclusive); int tty_buffer_space_avail(struct tty_port *port) { int space = port->buf.mem_limit - atomic_read(&port->buf.mem_used); + return max(space, 0); } EXPORT_SYMBOL_GPL(tty_buffer_space_avail); @@ -312,11 +313,13 @@ int tty_insert_flip_string_fixed_flag(struct tty_port *port, const unsigned char *chars, char flag, size_t size) { int copied = 0; + do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; int space = __tty_buffer_request_room(port, goal, flags); struct tty_buffer *tb = port->buf.tail; + if (unlikely(space == 0)) break; memcpy(char_buf_ptr(tb, tb->used), chars, space); @@ -348,10 +351,12 @@ int tty_insert_flip_string_flags(struct tty_port *port, const unsigned char *chars, const char *flags, size_t size) { int copied = 0; + do { int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); int space = tty_buffer_request_room(port, goal); struct tty_buffer *tb = port->buf.tail; + if (unlikely(space == 0)) break; memcpy(char_buf_ptr(tb, tb->used), chars, space); @@ -431,8 +436,10 @@ int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, size_t size) { int space = __tty_buffer_request_room(port, size, TTYB_NORMAL); + if (likely(space)) { struct tty_buffer *tb = port->buf.tail; + *chars = char_buf_ptr(tb, tb->used); if (~tb->flags & TTYB_NORMAL) memset(flag_buf_ptr(tb, tb->used), TTY_NORMAL, space); -- 2.8.1