Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp502904lqp; Thu, 4 Apr 2024 23:17:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXbnYdAyCcHFUl+8e9u01lPqtVZdXs2N4R/Fw4Z1bM7eeaeBN7GP1C8WVcQgx1XCHB78p8QTjVZ79R7AEbdTko6zij0ucTZ1xTy58xUHg== X-Google-Smtp-Source: AGHT+IEpKqgvFHTZk8NQkQbmwgLlSRpaAULxUBXvDG8wsw+gtyY0iNpLvOUqX0h5ez95jNZ9Xpro X-Received: by 2002:a17:902:eb8f:b0:1e2:573:eef7 with SMTP id q15-20020a170902eb8f00b001e20573eef7mr731198plg.0.1712297839833; Thu, 04 Apr 2024 23:17:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712297839; cv=pass; d=google.com; s=arc-20160816; b=r4zxemuNbV4wP+xCIZ4RbKaV66ZxR+RvGO3p8x92I0jeH/fDSuCRR7w2g2V5hzqhn+ ORmPieYkFTjNPJpZ2fyqP+nenj+JJQDh4OokrNdNz6U8ckEPP4zUn7ACHYqdOOgl8Xj/ rkQ8oVikHmw4FT0VKKcJXmXXVrOXgQ1KN7sBVwjfjl7dHTsdaMIYRJA5CQqLpjKI4Lir 6JNXCABtw4Y3WVbft6kdLgzvcoA0mmzSIFDPbtfQutJ5JstB0ZV662N9pYZt7Tf9koOH T4bEgKLdx9EZmr2W7xGSjaLFnCaWPnYfKfMTmEu7M1YigroSeB0ZZE9ZidtW82Z4HpqQ 5ufg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ItPWlZHwaN7pinqNHCK6XD7YM2FdOg1pXdEfYK0jPvQ=; fh=QJ8vJz0JL6c8fqQRAKc0NXCP+/F+4NYQGSVBSghPQr8=; b=wf9qoWjD2EDeZSpJLxxTea44VKmUzeStvEnzDIiNdyaLLqzZb8TpbFJvJzhjR6bRaq EMoaPm4a+8asehsVTpW0Zm91t6Uph4KXzOL4iw1UdSE8oQ/vCT0Y53zxUPW0wkOaMKJr cKYopOZMrRHI+y07oljJUEe+kilq5Qbs8TnBKvTDCF9imdVl7B0sQv/j+JDwlU7rRAUQ q7W0jwcMurk+1lQM8KY0PjXENDdOQXpg6QDaDlcsmNfJtqfKft/EJatq9vul2AF8ikdi r8vx6JC3cUjLSA6X7wKMjlZAbcMkRQkntKw/ej/Hbo80gMynAdOQVHXOlailY0Abj5Vq lvIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SR5IkoVW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l15-20020a170903244f00b001e0b5eee82asi792581pls.457.2024.04.04.23.17.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 23:17:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SR5IkoVW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132453-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5288BB25B25 for ; Fri, 5 Apr 2024 06:12:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BF3C55E44; Fri, 5 Apr 2024 06:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SR5IkoVW" 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 84F014C627; Fri, 5 Apr 2024 06:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297355; cv=none; b=Xn7ZqqMU3+QykJzzrkA1ihusIofkQhI3GpwH6rwDcE7IpPDWkIKEtCgkhMtGw//c+JW4lQMcX1AgbKgpV68IlfLRX2kIYPumy4E/AemKLuz/CK+Fz8Sopp8I5FpyD1F4acl1kcnujYfcgaF1WxmjbgLlhePsaa1lVddKENBUBr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297355; c=relaxed/simple; bh=5+bhGaEEsgnXQkvvlI11yrFLziNuirM9WUE4o2kU49s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PKI4O354IR1vnReQe9YR+GgQsqnZ2qTWjuofFHH4ps6z+t9eEoZ2giNyH2EvInEP5YfzkCkp80NUOko0wSXf4IwBhZOJlP6C/PkBVXiHqb58EVlibZ5exzPnenwTTXWBRvoxde7T3gH9tep9gKNce3U1qOOPugCBFYpkEaXkbb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SR5IkoVW; arc=none smtp.client-ip=10.30.226.201 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 Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Richard Genoud , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , linux-arm-kernel@lists.infradead.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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; -- 2.44.0