i2c: make i2c_bus_type const
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Dec 2023 15:22:43 +0000 (16:22 +0100)
committerWolfram Sang <wsa@kernel.org>
Thu, 18 Jan 2024 20:10:43 +0000 (21:10 +0100)
Now that the driver core can properly handle constant struct bus_type,
move the i2c_bus_type variable to be a constant structure as well, placing
it into read-only memory which can not be modified at runtime.

Note, the sound/soc/rockchip/rk3399_gru_sound.c also needed tweaking as
it decided to save off a pointer to a bus type for internal stuff, and
it was using the i2c_bus_type as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/i2c-core-base.c
include/linux/i2c.h
sound/soc/rockchip/rk3399_gru_sound.c

index f6c828bbd166a079504a1df243cf623474694753..3bd48d4b6318fe1fe83e3718c59713f354ff9878 100644 (file)
@@ -692,7 +692,7 @@ static struct attribute *i2c_dev_attrs[] = {
 };
 ATTRIBUTE_GROUPS(i2c_dev);
 
-struct bus_type i2c_bus_type = {
+const struct bus_type i2c_bus_type = {
        .name           = "i2c",
        .match          = i2c_device_match,
        .probe          = i2c_device_probe,
index e01fb1097868ceb1bae4a244d80aaf7e8772ef68..652ecb7abedae4b5bc3c451410139168702a63f9 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/swab.h>                /* for swab16 */
 #include <uapi/linux/i2c.h>
 
-extern struct bus_type i2c_bus_type;
+extern const struct bus_type i2c_bus_type;
 extern struct device_type i2c_adapter_type;
 extern struct device_type i2c_client_type;
 
index 1a504ebd3a0e9c6f0da9ea434633cf82c331c60b..6c89c7331229f0ac86b29f3bffb05f6623c98067 100644 (file)
@@ -446,7 +446,7 @@ static const struct rockchip_sound_route rockchip_routes[] = {
 
 struct dailink_match_data {
        const char *compatible;
-       struct bus_type *bus_type;
+       const struct bus_type *bus_type;
 };
 
 static const struct dailink_match_data dailink_match[] = {