cpufreq: Make kobj_type structure constant

Message ID 20230207-kobj_type-cpufreq-v1-1-c7fa2dbd0754@weissschuh.net
State New
Headers
Series cpufreq: Make kobj_type structure constant |

Commit Message

Thomas Weißschuh Feb. 7, 2023, 7:58 p.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 definition to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 drivers/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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

Best regards,
  

Comments

Viresh Kumar Feb. 8, 2023, 5:04 a.m. UTC | #1
On 07-02-23, 19:58, Thomas Weißschuh 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 definition to prevent
> modification at runtime.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  drivers/cpufreq/cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 7e56a42750ea..ceb1574417f9 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -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,
> 

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
  
Rafael J. Wysocki Feb. 9, 2023, 7:30 p.m. UTC | #2
On Wed, Feb 8, 2023 at 6:04 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> On 07-02-23, 19:58, Thomas Weißschuh 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 definition to prevent
> > modification at runtime.
> >
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > ---
> >  drivers/cpufreq/cpufreq.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 7e56a42750ea..ceb1574417f9 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -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,
> >
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Applied as 6.3 material, thanks!
  

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7e56a42750ea..ceb1574417f9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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,