drm/amdgpu: make kobj_type structures constant
authorThomas Weißschuh <linux@weissschuh.net>
Thu, 16 Feb 2023 01:07:27 +0000 (01:07 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 23 Feb 2023 22:35:59 +0000 (17:35 -0500)
Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.")
the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definitions to prevent
modification at runtime.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c

index b719852daa071a00c543485a75f43af2fb45e28b..ea040adb1f150fdc0cb7cf121928deb617a7cc60 100644 (file)
@@ -705,7 +705,7 @@ static void ip_hw_instance_release(struct kobject *kobj)
        kfree(ip_hw_instance);
 }
 
-static struct kobj_type ip_hw_instance_ktype = {
+static const struct kobj_type ip_hw_instance_ktype = {
        .release = ip_hw_instance_release,
        .sysfs_ops = &ip_hw_instance_sysfs_ops,
        .default_groups = ip_hw_instance_groups,
@@ -724,7 +724,7 @@ static void ip_hw_id_release(struct kobject *kobj)
        kfree(ip_hw_id);
 }
 
-static struct kobj_type ip_hw_id_ktype = {
+static const struct kobj_type ip_hw_id_ktype = {
        .release = ip_hw_id_release,
        .sysfs_ops = &kobj_sysfs_ops,
 };
@@ -787,18 +787,18 @@ static const struct sysfs_ops ip_die_entry_sysfs_ops = {
        .show = ip_die_entry_attr_show,
 };
 
-static struct kobj_type ip_die_entry_ktype = {
+static const struct kobj_type ip_die_entry_ktype = {
        .release = ip_die_entry_release,
        .sysfs_ops = &ip_die_entry_sysfs_ops,
        .default_groups = ip_die_entry_groups,
 };
 
-static struct kobj_type die_kobj_ktype = {
+static const struct kobj_type die_kobj_ktype = {
        .release = die_kobj_release,
        .sysfs_ops = &kobj_sysfs_ops,
 };
 
-static struct kobj_type ip_discovery_ktype = {
+static const struct kobj_type ip_discovery_ktype = {
        .release = ip_disc_release,
        .sysfs_ops = &kobj_sysfs_ops,
 };
index 4340d08f7607374f5c2a478c3f2d3ee87d3dcf70..fef1575cd0cf9d5ea4de3040a8a6a854d0ed4b18 100644 (file)
@@ -308,7 +308,7 @@ static const struct sysfs_ops amdgpu_xgmi_hive_ops = {
        .show = amdgpu_xgmi_show_attrs,
 };
 
-struct kobj_type amdgpu_xgmi_hive_type = {
+static const struct kobj_type amdgpu_xgmi_hive_type = {
        .release = amdgpu_xgmi_hive_release,
        .sysfs_ops = &amdgpu_xgmi_hive_ops,
        .default_groups = amdgpu_xgmi_hive_groups,