From patchwork Tue Dec 19 17:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Villeneuve X-Patchwork-Id: 181132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2094557dyi; Tue, 19 Dec 2023 09:22:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQlIJuJwGxzGJl10Kc58cKPPQlgProFnZ+O22g17P/ZiefWneZuOXvGWincOmADHVSSl8W X-Received: by 2002:a05:622a:45:b0:425:4043:8d3d with SMTP id y5-20020a05622a004500b0042540438d3dmr16809098qtw.88.1703006567227; Tue, 19 Dec 2023 09:22:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703006567; cv=none; d=google.com; s=arc-20160816; b=kBNq8V/Lci20047zKng2VvlqudHDPABFpddMNxLy2NVrjU9P4vk2slZNzTcUYndgzp 2s8kzaslwAEIlUdNikZBpILHV6/0cJxbqQ9GrN5jwpgonP6YXkPpyCENLqfa2WkmiYtt LgGhJvR8/5yrHz9fBslx8vmfWu+qZjB8VARwZurhX151cHNxwQ254em4oP/DvmVke35a yT+eDY0CSrgsvL8Rh4iF1DKTe3hKDaKzMY2Y8vAX0M73m/kZi161Y9AMVkcVWV8GRlX8 QQWQvrnmoFASjj+Qn3ZPqJyXghL+xGRBFmh8yqCR5AXbfYmK4A3LLsOWCwJHvDcetEdL cc3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:cc:to:from:dkim-signature; bh=vtaUMnMT8EggKRdVVV4aSCElIVRE59twHxnKq4mL2OA=; fh=cU7nueyVLD6PCX143V/gcz7kaNKnsE7kxUBegEucbAs=; b=eGd37FivFuZoQCFL84N7BxoLzPCa4z61TnsI3S4vdvzI0COY6BnpNFrQOwCVtBsqI2 CaE5W9MnP1DAh7qiC16an3D/y7hEtXkUBkKijno2qUzo7cfM0Zz6V69rgDQCp1JgWvrE s9uSlDfnBIIs9hjFr7FsFxk0m0paxQT9lQ9ZTZy3seWitQfVJ/XVoin4qcP+qhmywATY 3Q27sxbV6WPgicGOQHZj9XCNl+QW+869A1xB0lMCAEchJPZbNOf5vbhmlxVVxe/VYTS4 ckTtIeD2687z6qsOfRvU6L7ZJ+do0/3iGTEngpDOi7p8ZIUrwl21lvuBZuWkJA4cznM3 bbwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=BRM1bdus; spf=pass (google.com: domain of linux-kernel+bounces-5670-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5670-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j15-20020ac84c8f000000b00423ed2c8509si24462347qtv.308.2023.12.19.09.22.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:22:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5670-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=BRM1bdus; spf=pass (google.com: domain of linux-kernel+bounces-5670-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5670-ouuuleilei=gmail.com@vger.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E673A1C24FC9 for ; Tue, 19 Dec 2023 17:22:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B7493B29D; Tue, 19 Dec 2023 17:19:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="BRM1bdus" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (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 DE6D136AEA; Tue, 19 Dec 2023 17:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com 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=vtaUMnMT8EggKRdVVV4aSCElIVRE59twHxnKq4mL2OA=; b=BRM1bdusNTuln/ySzvTXmFKOSo 9z6XZgBwU9Xf0XVHKmHLt720y0NWn6X8yAPxzEmcMw3iA5cXwcZFsUEas5Anu7T0375scNgSSDLxS bzn6zxZiv4FSQ0md7r9VsTGrk2NXQasVTPfejHhytnSOi/FEh6MCtjUGnqRxgtIgWTwM=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:40128 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rFdkN-0007Ao-Pj; Tue, 19 Dec 2023 12:19:12 -0500 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org, jringle@gridpoint.com, kubakici@wp.pl, phil@raspberrypi.org, bo.svangard@embeddedart.se Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, Hugo Villeneuve Date: Tue, 19 Dec 2023 12:18:49 -0500 Message-Id: <20231219171903.3530985-6-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231219171903.3530985-1-hugo@hugovil.com> References: <20231219171903.3530985-1-hugo@hugovil.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.0 T_SCC_BODY_TEXT_LINE No description available. Subject: [PATCH 05/18] serial: sc16is7xx: use DECLARE_BITMAP for sc16is7xx_lines bitfield 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) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785731814049577948 X-GMAIL-MSGID: 1785731814049577948 From: Hugo Villeneuve Replace the explicit sc16is7xx_lines bitfield declaration with the generic macro DECLARE_BITMAP() to reserve just enough memory to contain all required bits. This also improves code self-documentation by showing the maximum number of bits required. This conversion now makes sc16is7xx_lines an array, so drop the "&" before sc16is7xx_lines in all bit access functions. Signed-off-by: Hugo Villeneuve Reviewed-by: Andy Shevchenko --- drivers/tty/serial/sc16is7xx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index 8a038a9be09e..597280a5d0f3 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -346,7 +346,7 @@ struct sc16is7xx_port { struct sc16is7xx_one p[]; }; -static unsigned long sc16is7xx_lines; +static DECLARE_BITMAP(sc16is7xx_lines, SC16IS7XX_MAX_DEVS); static struct uart_driver sc16is7xx_uart = { .owner = THIS_MODULE, @@ -1534,7 +1534,7 @@ static int sc16is7xx_probe(struct device *dev, SC16IS7XX_IOCONTROL_SRESET_BIT); for (i = 0; i < devtype->nr_uart; ++i) { - s->p[i].port.line = find_first_zero_bit(&sc16is7xx_lines, + s->p[i].port.line = find_first_zero_bit(sc16is7xx_lines, SC16IS7XX_MAX_DEVS); if (s->p[i].port.line >= SC16IS7XX_MAX_DEVS) { ret = -ERANGE; @@ -1585,7 +1585,7 @@ static int sc16is7xx_probe(struct device *dev, if (ret) goto out_ports; - set_bit(s->p[i].port.line, &sc16is7xx_lines); + set_bit(s->p[i].port.line, sc16is7xx_lines); /* Enable EFR */ sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, @@ -1644,7 +1644,7 @@ static int sc16is7xx_probe(struct device *dev, out_ports: for (i = 0; i < devtype->nr_uart; i++) - if (test_and_clear_bit(s->p[i].port.line, &sc16is7xx_lines)) + if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines)) uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); kthread_stop(s->kworker_task); @@ -1672,7 +1672,7 @@ static void sc16is7xx_remove(struct device *dev) for (i = 0; i < s->devtype->nr_uart; i++) { kthread_cancel_delayed_work_sync(&s->p[i].ms_work); - if (test_and_clear_bit(s->p[i].port.line, &sc16is7xx_lines)) + if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines)) uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); sc16is7xx_power(&s->p[i].port, 0); }