greybus: constify the struct device_type usage
authorRicardo B. Marliere <ricardo@marliere.net>
Mon, 19 Feb 2024 12:40:50 +0000 (09:40 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Mar 2024 14:13:10 +0000 (14:13 +0000)
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
greybus_hd_type, greybus_module_type, greybus_interface_type,
greybus_control_type, greybus_bundle_type and greybus_svc_type variables to
be constant structures as well, placing it into read-only memory which can
not be modified at runtime.

Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Reviewed-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20240219-device_cleanup-greybus-v1-1-babb3f65e8cc@marliere.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/greybus/bundle.c
drivers/greybus/control.c
drivers/greybus/hd.c
drivers/greybus/interface.c
drivers/greybus/module.c
drivers/greybus/svc.c
include/linux/greybus.h

index 84660729538b95cb8624080490025a68cba4fa54..a6e1cca06172f52d6f35b05da94642dbc3221ee4 100644 (file)
@@ -166,7 +166,7 @@ static const struct dev_pm_ops gb_bundle_pm_ops = {
        SET_RUNTIME_PM_OPS(gb_bundle_suspend, gb_bundle_resume, gb_bundle_idle)
 };
 
-struct device_type greybus_bundle_type = {
+const struct device_type greybus_bundle_type = {
        .name =         "greybus_bundle",
        .release =      gb_bundle_release,
        .pm =           &gb_bundle_pm_ops,
index 359a2584197397dc5351fa0f01b1c3ac5a79444f..b5cf49d09df229c79dda7efe78015a009d01bf6b 100644 (file)
@@ -436,7 +436,7 @@ static void gb_control_release(struct device *dev)
        kfree(control);
 }
 
-struct device_type greybus_control_type = {
+const struct device_type greybus_control_type = {
        .name =         "greybus_control",
        .release =      gb_control_release,
 };
index 72b21bf2d7d36a85cbfd05d261d760fa37f16205..e2f3496bddc3de2339008e13a02fb956e8bc3abf 100644 (file)
@@ -116,7 +116,7 @@ static void gb_hd_release(struct device *dev)
        kfree(hd);
 }
 
-struct device_type greybus_hd_type = {
+const struct device_type greybus_hd_type = {
        .name           = "greybus_host_device",
        .release        = gb_hd_release,
 };
index 9ec949a438ef6752607a5ac2708294f12879ce64..a88dc701289c932bc8bea0c7d4a274b1b9385a3f 100644 (file)
@@ -765,7 +765,7 @@ static const struct dev_pm_ops gb_interface_pm_ops = {
                           gb_interface_runtime_idle)
 };
 
-struct device_type greybus_interface_type = {
+const struct device_type greybus_interface_type = {
        .name =         "greybus_interface",
        .release =      gb_interface_release,
        .pm =           &gb_interface_pm_ops,
index 36f77f9e1d7439eaf9c16e871a3fd28a6a218bf5..7f7153a1dd602c1e7cf0bfb887009808c919ebf0 100644 (file)
@@ -81,7 +81,7 @@ static void gb_module_release(struct device *dev)
        kfree(module);
 }
 
-struct device_type greybus_module_type = {
+const struct device_type greybus_module_type = {
        .name           = "greybus_module",
        .release        = gb_module_release,
 };
index 0d7e749174a48c65eeb0c5918f68ed75b2726613..4256467fcd35976e011a5f226be38387ce9199b7 100644 (file)
@@ -1305,7 +1305,7 @@ static void gb_svc_release(struct device *dev)
        kfree(svc);
 }
 
-struct device_type greybus_svc_type = {
+const struct device_type greybus_svc_type = {
        .name           = "greybus_svc",
        .release        = gb_svc_release,
 };
index 92da9ec4f5f08224343e3da1464f3fcbb92c5cf3..2cc570ea63bfa5e182e60aac3bec8f4acaf47695 100644 (file)
@@ -106,12 +106,12 @@ struct dentry *gb_debugfs_get(void);
 
 extern const struct bus_type greybus_bus_type;
 
-extern struct device_type greybus_hd_type;
-extern struct device_type greybus_module_type;
-extern struct device_type greybus_interface_type;
-extern struct device_type greybus_control_type;
-extern struct device_type greybus_bundle_type;
-extern struct device_type greybus_svc_type;
+extern const struct device_type greybus_hd_type;
+extern const struct device_type greybus_module_type;
+extern const struct device_type greybus_interface_type;
+extern const struct device_type greybus_control_type;
+extern const struct device_type greybus_bundle_type;
+extern const struct device_type greybus_svc_type;
 
 static inline int is_gb_host_device(const struct device *dev)
 {