From patchwork Thu Nov 30 19:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 172051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp619538vqy; Thu, 30 Nov 2023 11:11:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeIN8f4GjhwvSum/I5fTLvUf2RTFhqXcsyWlMAyn9ysV+Pxap2dviosEcG85pPHC6/AffD X-Received: by 2002:a05:6a20:42a1:b0:187:5fe9:3046 with SMTP id o33-20020a056a2042a100b001875fe93046mr27463522pzj.0.1701371498378; Thu, 30 Nov 2023 11:11:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701371498; cv=none; d=google.com; s=arc-20160816; b=teHNDXvFgPOisxMX86tPoebeqSOIP8m9enCexxedQ7ErrktXycQsFyph0ubiEn/FYU Dox2qW+/N+Slodmoje3T5xA2HXs63dHAk4733CdNxUBVWs1xECSDjLHW6UfdJSH1cVKL 7Bmc1605e0V76tLB7nNweotfKoJUfAcVQr4m93CFV9mJz2d2wIyiIPs9ipsc8rGLZM9v +jba+4fPZ7YH0AXjPEi7/p7lloLdkfFol5zsXePknwS8y8oWiRcfN5l30it4dqxKlPF3 WoQJsit61nSBfSx6NF9mta7yEKK+QrIQV/7RDXifTDd1ozdZrxFn1wu0Of3ntoQJMvL2 wFAA== 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 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id jc39-20020a056a006ca700b006c0035ff9dasi1911875pfb.198.2023.11.30.11.11.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 11:11:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; 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 23.128.96.38 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 7A61A808BD1F; Thu, 30 Nov 2023 11:11:26 -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 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:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784017320363289492 X-GMAIL-MSGID: 1784017320363289492 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; }