linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpuidle: sysfs: make kobj_type structures constant
@ 2023-02-07 19:55 Thomas Weißschuh
  2023-02-09 20:05 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Weißschuh @ 2023-02-07 19:55 UTC (permalink / raw)
  To: Rafael J. Wysocki, Daniel Lezcano
  Cc: linux-pm, linux-kernel, 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>
---
 drivers/cpuidle/sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 2b496a53cbca..48948b171749 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -200,7 +200,7 @@ static void cpuidle_sysfs_release(struct kobject *kobj)
 	complete(&kdev->kobj_unregister);
 }
 
-static struct kobj_type ktype_cpuidle = {
+static const struct kobj_type ktype_cpuidle = {
 	.sysfs_ops = &cpuidle_sysfs_ops,
 	.release = cpuidle_sysfs_release,
 };
@@ -447,7 +447,7 @@ static void cpuidle_state_sysfs_release(struct kobject *kobj)
 	complete(&state_obj->kobj_unregister);
 }
 
-static struct kobj_type ktype_state_cpuidle = {
+static const struct kobj_type ktype_state_cpuidle = {
 	.sysfs_ops = &cpuidle_state_sysfs_ops,
 	.default_groups = cpuidle_state_default_groups,
 	.release = cpuidle_state_sysfs_release,
@@ -594,7 +594,7 @@ static struct attribute *cpuidle_driver_default_attrs[] = {
 };
 ATTRIBUTE_GROUPS(cpuidle_driver_default);
 
-static struct kobj_type ktype_driver_cpuidle = {
+static const struct kobj_type ktype_driver_cpuidle = {
 	.sysfs_ops = &cpuidle_driver_sysfs_ops,
 	.default_groups = cpuidle_driver_default_groups,
 	.release = cpuidle_driver_sysfs_release,

---
base-commit: 513c1a3d3f1982fb850c910937099525b0d35e24
change-id: 20230207-kobj_type-cpuidle-8310a467597b

Best regards,
-- 
Thomas Weißschuh <linux@weissschuh.net>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpuidle: sysfs: make kobj_type structures constant
  2023-02-07 19:55 [PATCH] cpuidle: sysfs: make kobj_type structures constant Thomas Weißschuh
@ 2023-02-09 20:05 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2023-02-09 20:05 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Rafael J. Wysocki, Daniel Lezcano, linux-pm, linux-kernel

On Tue, Feb 7, 2023 at 8:55 PM Thomas Weißschuh <linux@weissschuh.net> wrote:
>
> 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/cpuidle/sysfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
> index 2b496a53cbca..48948b171749 100644
> --- a/drivers/cpuidle/sysfs.c
> +++ b/drivers/cpuidle/sysfs.c
> @@ -200,7 +200,7 @@ static void cpuidle_sysfs_release(struct kobject *kobj)
>         complete(&kdev->kobj_unregister);
>  }
>
> -static struct kobj_type ktype_cpuidle = {
> +static const struct kobj_type ktype_cpuidle = {
>         .sysfs_ops = &cpuidle_sysfs_ops,
>         .release = cpuidle_sysfs_release,
>  };
> @@ -447,7 +447,7 @@ static void cpuidle_state_sysfs_release(struct kobject *kobj)
>         complete(&state_obj->kobj_unregister);
>  }
>
> -static struct kobj_type ktype_state_cpuidle = {
> +static const struct kobj_type ktype_state_cpuidle = {
>         .sysfs_ops = &cpuidle_state_sysfs_ops,
>         .default_groups = cpuidle_state_default_groups,
>         .release = cpuidle_state_sysfs_release,
> @@ -594,7 +594,7 @@ static struct attribute *cpuidle_driver_default_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(cpuidle_driver_default);
>
> -static struct kobj_type ktype_driver_cpuidle = {
> +static const struct kobj_type ktype_driver_cpuidle = {
>         .sysfs_ops = &cpuidle_driver_sysfs_ops,
>         .default_groups = cpuidle_driver_default_groups,
>         .release = cpuidle_driver_sysfs_release,
>
> ---

Applied as 6.3 material, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-09 20:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 19:55 [PATCH] cpuidle: sysfs: make kobj_type structures constant Thomas Weißschuh
2023-02-09 20:05 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).