spi: make spi_bus_type const
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jan 2024 10:32:50 +0000 (11:32 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 22 Jan 2024 00:06:53 +0000 (00:06 +0000)
Now that the driver core can properly handle constant struct bus_type,
move the spi_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Mark Brown <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://msgid.link/r/2024010549-erasure-swoop-1cc6@gregkh
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c
include/linux/spi/spi.h

index 7477a11e12be0e2bf47006ce9e579fdd9f1fda30..bc3d7c0ce6b43ee8776cb098c33f390451d3fd3f 100644 (file)
@@ -459,7 +459,7 @@ static void spi_shutdown(struct device *dev)
        }
 }
 
-struct bus_type spi_bus_type = {
+const struct bus_type spi_bus_type = {
        .name           = "spi",
        .dev_groups     = spi_dev_groups,
        .match          = spi_match_device,
index 471fe2ff9066b75e82795b92972905bbae3cc48c..f306aececeaf0a024b3fdfb3486997545dcf22bb 100644 (file)
@@ -36,7 +36,7 @@ struct spi_message;
  * INTERFACES between SPI master-side drivers and SPI slave protocol handlers,
  * and SPI infrastructure.
  */
-extern struct bus_type spi_bus_type;
+extern const struct bus_type spi_bus_type;
 
 /**
  * struct spi_statistics - statistics for spi transfers