From patchwork Mon Aug 21 14:11:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1823665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=tzhih88N; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=to7im9vW; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=EUIfH8X+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RTvd74VqJz1yNm for ; Tue, 22 Aug 2023 00:15:07 +1000 (AEST) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vrdmdq1DqPv1VnZefeBFfTn/r0mtQB/r2k8dgB34zh0=; b=tzhih88NczsckT mjH2+Pn2oDu7/yVPnH7oKRkEpkO+WyMTLCwks3Tv5DWouRJrbCdUhGTHToXIqU3EyUPuXPjiYlp5v As0R/oGjS+Vd4Ha7WJwQo8/XDlbKXiqZa8dNCRII7JyZwoVyaR60nbirykDl2IIjAtojRn0ef+LXr Au55t5p4X8+FWc8odAZ6QsVRM0fIv+OWtUCUhb4QIGJyKmFyVoKygS6O7xBQfZDdOKoIL510YCr5Y GHtc7a42H2q1oPbjBd5iRLCSJoqp5wRgXc92HOzj9I7bt8heG8q/wEr30kORe5WINMhlGUVckwsM+ cwQpgT3gzV/JyJ5ZV1BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qY5g5-00E9a5-03; Mon, 21 Aug 2023 14:14:45 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qY5g4-00E9Zi-0q for opensbi@bombadil.infradead.org; Mon, 21 Aug 2023 14:14:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=qePgFLsYo5Cbpekg2zGKthHp5GZyaeEGiwqWPx9XASM=; b=to7im9vW/ZnlivWFOPiQJ2GeCH NQXfXv1dndCSQWfBWzIoqNTxhY+3B+swSRrHG7aCn6KRRtwlLGNrw0xk1qDGMU6rGQJmm4HZyAoRK kAUn0C8dANsWaZvEWqj03nJhad7dWjFm72zvn/NE47/GaN2bNPa3mkC9jl3K+B8Nl9Ldsx+uFBNR9 aJun/2V+vCf2BE/T2w3gNDWXRggp0bU30cTpXuxHSdChbJwHK4O22C0qBz8vXgp2Dam+mOwR0CJso kWFzn0C9/JuPrQsJy4N/0fsefFic0079v20pf6a+KaDP588qwFJLl2HmThJfyHffhFkDM1oT9e0si gQgPFd3A==; Received: from m126.mail.126.com ([220.181.12.27]) by casper.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1qY5fy-00AdfY-NM for opensbi@lists.infradead.org; Mon, 21 Aug 2023 14:14:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=qePgF LsYo5Cbpekg2zGKthHp5GZyaeEGiwqWPx9XASM=; b=EUIfH8X+V8M5oNDmvZN1v zlYJXymU8wHn9Tjhnff5VkyNsXYwgK3/90eLPVSTWrJNByMH1RRH1p4xiU5oi3uN LYYbYu5lR6WPlpbl1w11We2Crno/jh1s4IWPGVkH2SYWqlEYPcAhO7WYhW8jzSd7 OCu7TcC6pqk6iPCu/OikTg= Received: from t490.lan (unknown [124.65.175.6]) by zwqz-smtp-mta-g2-1 (Coremail) with SMTP id _____wCXPwekcONkIjYBAA--.1545S2; Mon, 21 Aug 2023 22:11:50 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH] lib: sbi: improve the definition of SBI_IPI_EVENT_MAX Date: Mon, 21 Aug 2023 22:11:45 +0800 Message-Id: <20230821141145.23695-1-wxjstz@126.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-CM-TRANSID: _____wCXPwekcONkIjYBAA--.1545S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Gw1DArWrCF43Xw48Jr4xZwb_yoW8JF1DpF 1DCFWUGw4IyFZ2g3y7CayUWa1rWws5Ga4jgFW7W3ySvFn5Z34rKF4SqFyUta13WrWrZ3Z8 Ja40vryF9r1UZrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pE-eOgUUUUU= X-Originating-IP: [124.65.175.6] X-CM-SenderInfo: pz0m23b26rjloofrz/1tbi5AfSOlpEGnBidgAAsr X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230821_151439_339534_25B59B30 X-CRM114-Status: UNSURE ( 8.48 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.4.6 on casper.infradead.org summary: Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The previous definition had the assumption that the machine word length is equal to the word length of LONG. Remove this assumption and add a static check to prevent errors in subsequent modifications. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- include/sbi/sbi_ipi.h | 2 +- lib/sbi/sbi_ipi.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/sbi/sbi_ipi.h b/include/sbi/sbi_ipi.h index c64f422..6b5e260 100644 --- a/include/sbi/sbi_ipi.h +++ b/include/sbi/sbi_ipi.h @@ -14,7 +14,7 @@ /* clang-format off */ -#define SBI_IPI_EVENT_MAX __riscv_xlen +#define SBI_IPI_EVENT_MAX (8 * __SIZEOF_LONG__) /* clang-format on */ diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index ad09154..0d8edab 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -27,6 +27,11 @@ struct sbi_ipi_data { unsigned long ipi_type; }; +_Static_assert( + 8 * sizeof(((struct sbi_ipi_data*)0)->ipi_type) == SBI_IPI_EVENT_MAX, + "type of sbi_ipi_data.ipi_type has changed, please redefine SBI_IPI_EVENT_MAX" + ); + static unsigned long ipi_data_off; static const struct sbi_ipi_device *ipi_dev = NULL; static const struct sbi_ipi_event_ops *ipi_ops_array[SBI_IPI_EVENT_MAX];