From patchwork Tue Mar 19 09:53:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 13596512 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87A07C54E5D for ; Tue, 19 Mar 2024 09:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sBjhEiInXqHgEyqH7c9aOVYlIYtte1O1EpjlJo0QnNE=; b=mT3bKZCneNyfmd 8puRteEpzj1NrXE4QNgXvn6sdRH9ph9vFNGpfFafPJTBPqA5hhyHlzz8EfCCJ+qKTz0RVYC//8CIm 9VrYGyY6BPfcUPrjyb63H2wIFgkZ1yZi8gLcjlPLatT/Ks9a9jcgqCS0nrhgv/15/cIJZhh9zVsRi twCfrcv3azIADOT0J/5uxOhrGakt7ebZYf6fr62SU9VO/E//wd8P9wwyofMdMgJ0iexfN24eF+4Z9 AIftA0Rz5vBqCq9JC24wDVq7i+VXLbou00Ap2u7Vi0LUGQqdyrNDXZ5AL1KVmTaloJfMEl8re3f1q rHxK83d3WeroHlSM68EQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmWAl-0000000CBZC-2AXI; Tue, 19 Mar 2024 09:54:19 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmWAX-0000000CBSe-26ma for linux-arm-kernel@lists.infradead.org; Tue, 19 Mar 2024 09:54:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E976560E74; Tue, 19 Mar 2024 09:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCCC7C433F1; Tue, 19 Mar 2024 09:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710842044; bh=5+bhGaEEsgnXQkvvlI11yrFLziNuirM9WUE4o2kU49s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GUwsaYP7lie6Y6XI47LkB7londD7Gp3FNQROjsfd3lbl3fgR+6zQeFMYnIzuOIzIh 22bX7FIOs56cbSzowCk1XvOV7TuU7zTHynTDI41tf0RX1lzL/VIlH/9G7In0/1Fn4K wlRK9FVlNrNGvwHSxND1cYZt+CQ5wrXttsOQ6D3baU456ArY/vq4xNTaN1f158hKkV H21etsIJ/eAab8AAR6dyS/evvGDWvSuAnv3NFZoRzMJk2+MtLk087KMXku0UYiEV0v 3hElb9xSv3cSm/ExolGg/cakzvfv6aJ2PUDG6K5mHptb5QnuAmXJgJlySGNNdgRsuo 1f+4zAJumFMmQ== From: "Jiri Slaby (SUSE)" To: linux-serial@vger.kernel.org Subject: [RFT 14/15] tty: atmel_serial: define macro for RX size Date: Tue, 19 Mar 2024 10:53:14 +0100 Message-ID: <20240319095315.27624-16-jirislaby@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240319095315.27624-1-jirislaby@kernel.org> References: <20240319095315.27624-1-jirislaby@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240319_025405_693113_45AD39BA X-CRM114-Status: GOOD ( 13.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Richard Genoud , Claudiu Beznea , linux-kernel@vger.kernel.org, "Jiri Slaby \(SUSE\)" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It is repeated in the code and there is also a big warning by ATMEL_SERIAL_RINGSIZE. So define ATMEL_SERIAL_RX_SIZE and use it appropriatelly. The macro uses array_size() and kmalloc_array() is switched to kmalloc(). Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Genoud Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: linux-arm-kernel@lists.infradead.org --- drivers/tty/serial/atmel_serial.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 69ec80ffc97b..5cde5077c429 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -96,7 +96,9 @@ struct atmel_uart_char { * can contain up to 1024 characters in PIO mode and up to 4096 characters in * DMA mode. */ -#define ATMEL_SERIAL_RINGSIZE 1024 +#define ATMEL_SERIAL_RINGSIZE 1024 +#define ATMEL_SERIAL_RX_SIZE array_size(sizeof(struct atmel_uart_char), \ + ATMEL_SERIAL_RINGSIZE) /* * at91: 6 USARTs and one DBGU port (SAM9260) @@ -1208,7 +1210,7 @@ static int atmel_prepare_rx_dma(struct uart_port *port) BUG_ON(!PAGE_ALIGNED(ring->buf)); sg_set_page(&atmel_port->sg_rx, virt_to_page(ring->buf), - sizeof(struct atmel_uart_char) * ATMEL_SERIAL_RINGSIZE, + ATMEL_SERIAL_RX_SIZE, offset_in_page(ring->buf)); nent = dma_map_sg(port->dev, &atmel_port->sg_rx, @@ -2947,9 +2949,7 @@ static int atmel_serial_probe(struct platform_device *pdev) if (!atmel_use_pdc_rx(&atmel_port->uart)) { ret = -ENOMEM; - data = kmalloc_array(ATMEL_SERIAL_RINGSIZE, - sizeof(struct atmel_uart_char), - GFP_KERNEL); + data = kmalloc(ATMEL_SERIAL_RX_SIZE, GFP_KERNEL); if (!data) goto err_clk_disable_unprepare; atmel_port->rx_ring.buf = data;