Skip to contentSkip to conversation

cpufreq: Make kobj_type structure constant

PATCH Applied Thomas Weißschuh 3 participants 3 messages Feb 7, 2023 – Feb 9, 2023 CPU frequency scaling framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: 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.

---
 drivers/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +1 -1
index 7e56a42750ea..ceb1574417f9 100644
@@ -993,7 +993,7 @@ static const struct sysfs_ops sysfs_ops = {
 	.store	= store,
 };
 
-static struct kobj_type ktype_cpufreq = {
+static const struct kobj_type ktype_cpufreq = {
 	.sysfs_ops	= &sysfs_ops,
 	.default_groups	= cpufreq_groups,
 	.release	= cpufreq_sysfs_release,

---
base-commit: 513c1a3d3f1982fb850c910937099525b0d35e24
change-id: 20230207-kobj_type-cpufreq-fdad53f0b538

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · 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 definition to prevent modification at runtime.

---
 drivers/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +0 -0
index 7e56a42750ea..ceb1574417f9 100644

drivers/cpufreq/cpufreq.c static const struct sysfs_ops sysfs_ops = { · line 999

Quoted 8 lines
drivers/cpufreq/cpufreq.c +1 -1
@@ -993,7 +993,7 @@ static const struct sysfs_ops sysfs_ops = {
 	.store	= store,
 };
 
-static struct kobj_type ktype_cpufreq = {
+static const struct kobj_type ktype_cpufreq = {
 	.sysfs_ops	= &sysfs_ops,
 	.default_groups	= cpufreq_groups,
 	.release	= cpufreq_sysfs_release,
Signature · 1 line
viresh
maintainer Applied
#2 lore raw
Quoted 21 lines · Viresh Kumar
Quoted 19 lines · 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 definition to prevent modification at runtime.

---
 drivers/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq.c +0 -0
index 7e56a42750ea..ceb1574417f9 100644
@@ -993,7 +993,7 @@ static const struct sysfs_ops sysfs_ops = {
      .store  = store,
 };
 
Quoted 8 lines

drivers/cpufreq/cpufreq.c static const struct sysfs_ops sysfs_ops = { · line 999

Quoted 6 lines
drivers/cpufreq/cpufreq.c +1 -1
-static struct kobj_type ktype_cpufreq = {
+static const struct kobj_type ktype_cpufreq = {
      .sysfs_ops      = &sysfs_ops,
      .default_groups = cpufreq_groups,
      .release        = cpufreq_sysfs_release,

Applied as 6.3 material, thanks!