2023-02-07 16:41:13

by Thomas Weißschuh

[permalink] [raw]
Subject: [PATCH 3/3] x86/platform/uv: Make kobj_type structure constant

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 definition to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <[email protected]>
---
drivers/platform/x86/uv_sysfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/uv_sysfs.c b/drivers/platform/x86/uv_sysfs.c
index 73fc38ee7430..38d1b692d3c0 100644
--- a/drivers/platform/x86/uv_sysfs.c
+++ b/drivers/platform/x86/uv_sysfs.c
@@ -203,7 +203,7 @@ static const struct sysfs_ops hub_sysfs_ops = {
.show = hub_type_show,
};

-static struct kobj_type hub_attr_type = {
+static const struct kobj_type hub_attr_type = {
.release = hub_release,
.sysfs_ops = &hub_sysfs_ops,
.default_groups = uv_hub_groups,
@@ -356,7 +356,7 @@ static const struct sysfs_ops uv_port_sysfs_ops = {
.show = uv_port_type_show,
};

-static struct kobj_type uv_port_attr_type = {
+static const struct kobj_type uv_port_attr_type = {
.release = uv_port_release,
.sysfs_ops = &uv_port_sysfs_ops,
.default_groups = uv_port_groups,
@@ -528,7 +528,7 @@ static const struct sysfs_ops uv_pci_top_sysfs_ops = {
.show = pci_top_type_show,
};

-static struct kobj_type uv_pci_top_attr_type = {
+static const struct kobj_type uv_pci_top_attr_type = {
.release = uv_pci_top_release,
.sysfs_ops = &uv_pci_top_sysfs_ops,
};

--
2.39.1



2023-02-07 19:49:12

by Ernst, Justin

[permalink] [raw]
Subject: RE: [PATCH 3/3] x86/platform/uv: Make kobj_type structure constant

> 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 definition to prevent
> modification at runtime.
>
> Signed-off-by: Thomas Weißschuh <[email protected]>

Looks good. Thanks for the patch!

Reviewed-by: Justin Ernst <[email protected]>

> ---
> drivers/platform/x86/uv_sysfs.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/uv_sysfs.c b/drivers/platform/x86/uv_sysfs.c
> index 73fc38ee7430..38d1b692d3c0 100644
> --- a/drivers/platform/x86/uv_sysfs.c
> +++ b/drivers/platform/x86/uv_sysfs.c
> @@ -203,7 +203,7 @@ static const struct sysfs_ops hub_sysfs_ops = {
> .show = hub_type_show,
> };
>
> -static struct kobj_type hub_attr_type = {
> +static const struct kobj_type hub_attr_type = {
> .release = hub_release,
> .sysfs_ops = &hub_sysfs_ops,
> .default_groups = uv_hub_groups,
> @@ -356,7 +356,7 @@ static const struct sysfs_ops uv_port_sysfs_ops = {
> .show = uv_port_type_show,
> };
>
> -static struct kobj_type uv_port_attr_type = {
> +static const struct kobj_type uv_port_attr_type = {
> .release = uv_port_release,
> .sysfs_ops = &uv_port_sysfs_ops,
> .default_groups = uv_port_groups,
> @@ -528,7 +528,7 @@ static const struct sysfs_ops uv_pci_top_sysfs_ops = {
> .show = pci_top_type_show,
> };
>
> -static struct kobj_type uv_pci_top_attr_type = {
> +static const struct kobj_type uv_pci_top_attr_type = {
> .release = uv_pci_top_release,
> .sysfs_ops = &uv_pci_top_sysfs_ops,
> };
>
> --
> 2.39.1