[PATCH v1 2/4] spidev: Convert BUILD_BUG_ON() to static_assert()

From: Andy Shevchenko
Date: Wed Mar 23 2022 - 10:02:22 EST


static_assert() is a preferred method to fail build when the certain
constraints are not met. Convert BUILD_BUG_ON() to static_assert().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/spi/spidev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index daeaa4a30290..125da8d0e719 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -46,6 +46,7 @@

static DECLARE_BITMAP(minors, N_SPI_MINORS);

+static_assert(N_SPI_MINORS > 0 && N_SPI_MINORS <= 256);

/* Bit masks for spi_device.mode management. Note that incorrect
* settings for some settings can cause *lots* of trouble for other
@@ -856,7 +857,6 @@ static int __init spidev_init(void)
* that will key udev/mdev to add/remove /dev nodes. Last, register
* the driver which manages those device numbers.
*/
- BUILD_BUG_ON(N_SPI_MINORS > 256);
status = register_chrdev(SPIDEV_MAJOR, "spi", &spidev_fops);
if (status < 0)
return status;
--
2.35.1