From patchwork Fri Apr 5 06:08:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 13618569 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 14A7ACD11C2 for ; Fri, 5 Apr 2024 06:09:32 +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=POaciL2O+q0+GV HAFHcd+kPBn2K1L4mBw9tzWHc1SeTK5cPGNNYZ8H1c/YjLjJRAC3tMrbO/UxJCNWmBvIKX95Jt2Z5 E1F1dHW4RNF7X5YSeSS5eY9mmBES0KP7CftFrvekzjBJcsHArdyWM8c3ue/bf6pX2U+UHk8VBtk5p cYZl73YrXr609H+ILunHadm2OVGHDxHSGAd54y6r9yUPYbsaXXTOYfWFY+tCw9dIbS3MskFKinQHY 99xRA70foCfkxqc5pw1fLfe74gp4rm48Gm3YbqlYcfL1GXEdZQCm2bRWuqLtP8UVBkwpd6w36YFKF 9qJLzwem1PW+JfPxnKVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsclM-00000005OlE-0EPz; Fri, 05 Apr 2024 06:09:20 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rsclJ-00000005Oiw-1ykY for linux-arm-kernel@lists.infradead.org; Fri, 05 Apr 2024 06:09:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 72B74CE360E; Fri, 5 Apr 2024 06:09:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 202EDC433F1; Fri, 5 Apr 2024 06:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712297355; bh=5+bhGaEEsgnXQkvvlI11yrFLziNuirM9WUE4o2kU49s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SR5IkoVWCThIz/IBG4dzQ2NMBOZgCa6oO3mHsRDzKtpnJI73i/leg0yhmXB/ELmoo k4tJVUb5AYY5fzBvjdbtoGwC7z571VIunje+PC3+0xHmQUzw1S6C2e1HyoVJpEGRR/ GNdgND2effh9za7S8E1C7Ho5IKLUTJyHiRL8kaa9hlKzm05fpge3Gyi4OWord4zqVo hF7fwsJ+JIfygO36D2ObOsvpI8Nb8t5wTYEyhZIsd+9e++sd170qbM9glC/WnukVk6 NvpxDyXWqS5ONegWMu11GvD322p2uJ6xULNYpFWk9xYyaDnPE17xrmxCMyAdOrAPeC 9+F2fxqtatrpg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Subject: [PATCH 14/15] tty: atmel_serial: define macro for RX size Date: Fri, 5 Apr 2024 08:08:25 +0200 Message-ID: <20240405060826.2521-15-jirislaby@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405060826.2521-1-jirislaby@kernel.org> References: <20240405060826.2521-1-jirislaby@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240404_230917_722826_C09A2790 X-CRM114-Status: GOOD ( 13.37 ) 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 , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Claudiu Beznea , "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;