Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp538836rdb; Thu, 30 Nov 2023 11:11:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJQ/cEiMgti/xOX/mVpqphN6wqMqMJb8xwYjlN8Zwyz72KcHTxfr8YnPhkOqWiN1PMUftl X-Received: by 2002:a05:6808:3c5:b0:3ac:b73a:757f with SMTP id o5-20020a05680803c500b003acb73a757fmr474666oie.39.1701371492274; Thu, 30 Nov 2023 11:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701371492; cv=none; d=google.com; s=arc-20160816; b=XuN0D1ntRfdUbleAFV06ijwki9Mtz6KamiongyCKrLR1Jtl1jHutPLdCyhYejUHCE+ ZgVkqKtr1lmI0eLEJNvAiTpzeU6G2p51V6nRbO+0dNKEEQMqfmA3PVcePX6/CnO7j9X7 1PfCFp4PwbwnPWDRv5vpEehJbz48WajCostF/rF+oNmMP4wqfWCkQ20Kq1IYpMQpDanG pux9Hkwx4ynw4zqd8l3gmK9qUia9ehJjT4lpbUe6aYNVDx0xPftrVnFuVZPVg2KHGZfs NuExS2xtmDuhv8JKZob4sOHUPgf3kzUZP6CoVfljIRlDYgM7JERvxQXE0UAXs4A+RXn6 5aKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=E3rFIY36xk7w67SNdqRVr/ancYZH1uNQAprnseO50p4=; fh=TwCzphd3GvIn5DzVyM5Tad6hmxhn7TdVF0rNjlsRujg=; b=0vYdAC19G9xMxQMut5rU2U4fmlNNzqfCBm9oe68U4hbK4UBuf0bRXjA6niFDe69xXj CPjgqVak0oFY1OkARYbe5uVjNrOYdyu+s1J8tiRZM7fug1WlTezty6yVUKqL3mPE9/tk JiVzJg/H6DQSSb0JvOI/FaWhL6acr6w7ENjeOzhVUeZzTHERhnI3MJ6x6oHACVVeaRnM ylv5FObgWmYY9m/1kQq+xL4QPNs378kVfl9dNh7wVp9pDm45ywyXLplgyS7QB/8aZWf1 1kSmFtwMH64H1ZKXCyOY/T5HDwZ0qnHzpWY21tNAFmtHGijtStu0K4LqGuwBYjMu44sR QDIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=ms58PUp6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id 18-20020a630212000000b005c62647b24asi1850621pgc.193.2023.11.30.11.11.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 11:11:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=ms58PUp6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D9D4C80DD86F; Thu, 30 Nov 2023 11:11:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346820AbjK3TLE (ORCPT + 99 others); Thu, 30 Nov 2023 14:11:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346800AbjK3TKy (ORCPT ); Thu, 30 Nov 2023 14:10:54 -0500 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2993F10F1; Thu, 30 Nov 2023 11:11:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=E3rFIY36xk7w67SNdqRVr/ancYZH1uNQAprnseO50p4=; b=ms58PUp6WubC4rGPiAMDw64R1L U5xxgzPBiwvEomi5ygL3iiuZDEcX31ej7lxIAUlwWIsQYO/hxrASVbf8B7bO6Nug/+Lr6YTvlmJaQ w3HJhV/1bR6WNIPpJmTgri80yzhuq8q4HZT+4/Lv31nYPm7EwLyMUsJXuJGJug6ALLFc=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:48272 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1r8mR8-0003sb-Mc; Thu, 30 Nov 2023 14:10:59 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org, hvilleneuve@dimonoff.com Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com Date: Thu, 30 Nov 2023 14:10:47 -0500 Message-Id: <20231130191050.3165862-6-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231130191050.3165862-1-hugo@hugovil.com> References: <20231130191050.3165862-1-hugo@hugovil.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_CSS autolearn=unavailable autolearn_force=no version=3.4.6 Subject: [PATCH 5/7] serial: sc16is7xx: improve sc16is7xx_regmap_name() buffer size computation X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 30 Nov 2023 11:11:30 -0800 (PST) From: Hugo Villeneuve Define macro for regmap port name suffix and use it in addition to SC16IS7XX_MAX_PORTS to automatically compute the required buffer size to hold the name. This helps with code readability by making it more obvious what is the required size of the buffer. Signed-off-by: Hugo Villeneuve --- drivers/tty/serial/sc16is7xx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 750c55b93f5e..b02e6c79da67 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #define SC16IS7XX_NAME "sc16is7xx" +#define SC16IS7XX_PORT_NAME_SUFFIX "port" /* Used for regmap name. */ #define SC16IS7XX_MAX_DEVS 8 #define SC16IS7XX_MAX_PORTS 2 /* Maximum number of UART ports per IC. */ @@ -1700,9 +1702,9 @@ static struct regmap_config regcfg = { static const char *sc16is7xx_regmap_name(unsigned int port_id) { - static char buf[6]; + static char buf[sizeof(SC16IS7XX_PORT_NAME_SUFFIX __stringify(SC16IS7XX_MAX_PORTS))]; - snprintf(buf, sizeof(buf), "port%u", port_id); + snprintf(buf, sizeof(buf), SC16IS7XX_PORT_NAME_SUFFIX "%u", port_id); return buf; } -- 2.39.2