diff mbox series

drm/amdgpu: make kobj_type structures constant

Message ID 20230216-kobj_type-amdgpu-v1-1-b382ab606dc7@weissschuh.net (mailing list archive)
State New, archived
Headers show
Series drm/amdgpu: make kobj_type structures constant | expand

Commit Message

Thomas Weißschuh Feb. 16, 2023, 1:07 a.m. UTC
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.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 10 +++++-----
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c      |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)


---
base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
change-id: 20230216-kobj_type-amdgpu-4d3f0e1e05d4

Best regards,

Comments

Christian König Feb. 16, 2023, 6:58 a.m. UTC | #1
Am 16.02.23 um 02:07 schrieb Thomas Weißschuh:
> 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.
>
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 10 +++++-----
>   drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c      |  2 +-
>   2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> index 1bbd56029a4f..8e04952e5144 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> @@ -704,7 +704,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,
> @@ -723,7 +723,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,
>   };
> @@ -786,18 +786,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,
>   };
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
> index 4b9e7b050ccd..6d13ce6ec9cc 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
> @@ -228,7 +228,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,
>
> ---
> base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
> change-id: 20230216-kobj_type-amdgpu-4d3f0e1e05d4
>
> Best regards,
Alex Deucher Feb. 17, 2023, 8:13 p.m. UTC | #2
Applied.  Thanks!

Alex

On Thu, Feb 16, 2023 at 1:59 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 16.02.23 um 02:07 schrieb Thomas Weißschuh:
> > 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.
> >
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 10 +++++-----
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c      |  2 +-
> >   2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> > index 1bbd56029a4f..8e04952e5144 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> > @@ -704,7 +704,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,
> > @@ -723,7 +723,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,
> >   };
> > @@ -786,18 +786,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,
> >   };
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
> > index 4b9e7b050ccd..6d13ce6ec9cc 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
> > @@ -228,7 +228,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,
> >
> > ---
> > base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
> > change-id: 20230216-kobj_type-amdgpu-4d3f0e1e05d4
> >
> > Best regards,
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
index 1bbd56029a4f..8e04952e5144 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -704,7 +704,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,
@@ -723,7 +723,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,
 };
@@ -786,18 +786,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,
 };
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 4b9e7b050ccd..6d13ce6ec9cc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -228,7 +228,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,