From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B0FF3D71 for ; Thu, 10 Aug 2023 10:39:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9572BC433C7; Thu, 10 Aug 2023 10:39:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691663944; bh=dtMhaLdCEBf8LyDEChVuL94sp23JhfU16F+5lzQnbJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjBdC+oZiqPod2lHLaj/kELB0xCrFiTTiBsEm8ho0n4F6TCHb7TyvPjz2ORb8Pdop COsIiqW98YQcnTbKaeEjrtgPMUzTzERTPIgDISWDikITpY8V+vM3Yew03odqPWsu5Y 7z3VIdTaWXWzx+XQXZjWsgiMrfzuSkQMn0pu5yMQ/8Ca86xDAOSZV+y1h3kk6YVrPj BOtk49zshQ++ODJ8/ypTvKOS4dc06NIb2hhiSzfF7zoI8yNPacUNxI8z9B4FG2mhuA OYzEEmzxpHpRUWtDpKTK1T8PyLf7FEZY9SUP/ahStoG/sbOqmFclybG3eTgTDoHz7U 4nmP5REqdPhog== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Dan Carpenter , linux-staging@lists.linux.dev Subject: [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Date: Thu, 10 Aug 2023 12:39:00 +0200 Message-ID: <20230810103900.19353-1-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit len and remain can never be negative in gdm_tty_write(). So remove such a check and move the check of remaining bytes to the loop condition. This way, the preceding 'if' is now superfluous too. Fix all that and make the code cleaner. Signed-off-by: Jiri Slaby (SUSE) Reported-by: Dan Carpenter Cc: linux-staging@lists.linux.dev --- drivers/staging/gdm724x/gdm_tty.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index cbaaa8fa7474..67d9bf41e836 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -158,10 +158,7 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len) if (!gdm_tty_ready(gdm)) return -ENODEV; - if (!len) - return 0; - - while (1) { + while (remain) { size_t sending_len = min(MUX_TX_MAX_SIZE, remain); gdm->tty_dev->send_func(gdm->tty_dev->priv_dev, (void *)(buf + sent_len), @@ -171,8 +168,6 @@ static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len) gdm); sent_len += sending_len; remain -= sending_len; - if (remain <= 0) - break; } return len; -- 2.41.0