thunderbolt: Constify the struct device_type usage
authorRicardo B. Marliere <ricardo@marliere.net>
Mon, 19 Feb 2024 12:45:50 +0000 (09:45 -0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Mon, 26 Feb 2024 07:15:49 +0000 (09:15 +0200)
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
tb_domain_type, tb_retimer_type, tb_switch_type, usb4_port_device_type,
tb_service_type and tb_xdomain_type variables to be constant structures as
well, placing it into read-only memory which can not be modified at
runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/domain.c
drivers/thunderbolt/retimer.c
drivers/thunderbolt/switch.c
drivers/thunderbolt/tb.h
drivers/thunderbolt/usb4_port.c
drivers/thunderbolt/xdomain.c
include/linux/thunderbolt.h

index 1d915a6c61a4a69176c61900e481c9e8739430b6..0023017299f7613d151d793bea0dc9519dc9f9c2 100644 (file)
@@ -326,7 +326,7 @@ static void tb_domain_release(struct device *dev)
        kfree(tb);
 }
 
-struct device_type tb_domain_type = {
+const struct device_type tb_domain_type = {
        .name = "thunderbolt_domain",
        .release = tb_domain_release,
 };
index d49d6628dbf29970a398e381b1603875ec1d7f0c..6bb49bdcd6c18e6f1f56b981b40c522f67db0861 100644 (file)
@@ -356,7 +356,7 @@ static void tb_retimer_release(struct device *dev)
        kfree(rt);
 }
 
-struct device_type tb_retimer_type = {
+const struct device_type tb_retimer_type = {
        .name = "thunderbolt_retimer",
        .groups = retimer_groups,
        .release = tb_retimer_release,
index bca6f28c553b085ddb8ac6a4e8ddf6f2915543f5..5a617ea285a72d708b70945b1e8beb7851c85547 100644 (file)
@@ -2327,7 +2327,7 @@ static const struct dev_pm_ops tb_switch_pm_ops = {
                           NULL)
 };
 
-struct device_type tb_switch_type = {
+const struct device_type tb_switch_type = {
        .name = "thunderbolt_device",
        .release = tb_switch_release,
        .uevent = tb_switch_uevent,
index 8e87d1a0005c727e24f9f1a2d6de145d2f6073d0..feed8ecaf712e84409daacb6a55b3ef121cb05f0 100644 (file)
@@ -749,10 +749,10 @@ static inline int tb_port_write(struct tb_port *port, const void *buffer,
 struct tb *icm_probe(struct tb_nhi *nhi);
 struct tb *tb_probe(struct tb_nhi *nhi);
 
-extern struct device_type tb_domain_type;
-extern struct device_type tb_retimer_type;
-extern struct device_type tb_switch_type;
-extern struct device_type usb4_port_device_type;
+extern const struct device_type tb_domain_type;
+extern const struct device_type tb_retimer_type;
+extern const struct device_type tb_switch_type;
+extern const struct device_type usb4_port_device_type;
 
 int tb_domain_init(void);
 void tb_domain_exit(void);
index e355bfd6343ff0d0616d1917fbcef9acf123023d..5150879888cac7f2bfa8693fe43b4116829b6f61 100644 (file)
@@ -243,7 +243,7 @@ static void usb4_port_device_release(struct device *dev)
        kfree(usb4);
 }
 
-struct device_type usb4_port_device_type = {
+const struct device_type usb4_port_device_type = {
        .name = "usb4_port",
        .groups = usb4_port_device_groups,
        .release = usb4_port_device_release,
index b48df88981bdadb327b6b77e30ed0874f342672a..940ae97987ff3821ee312a6c1603cbea9d7b231f 100644 (file)
@@ -1002,7 +1002,7 @@ static void tb_service_release(struct device *dev)
        kfree(svc);
 }
 
-struct device_type tb_service_type = {
+const struct device_type tb_service_type = {
        .name = "thunderbolt_service",
        .groups = tb_service_attr_groups,
        .uevent = tb_service_uevent,
@@ -1893,7 +1893,7 @@ static const struct dev_pm_ops tb_xdomain_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(tb_xdomain_suspend, tb_xdomain_resume)
 };
 
-struct device_type tb_xdomain_type = {
+const struct device_type tb_xdomain_type = {
        .name = "thunderbolt_xdomain",
        .release = tb_xdomain_release,
        .pm = &tb_xdomain_pm_ops,
index 2c835e5c41f6303da0d86e25619a5dbedc4743d3..4338ea9ac4fd9a62bd25b71ccd448386f682487d 100644 (file)
@@ -87,8 +87,8 @@ struct tb {
 };
 
 extern const struct bus_type tb_bus_type;
-extern struct device_type tb_service_type;
-extern struct device_type tb_xdomain_type;
+extern const struct device_type tb_service_type;
+extern const struct device_type tb_xdomain_type;
 
 #define TB_LINKS_PER_PHY_PORT  2