powercap: constify powercap_zone_ops and powercap_zone_constraint_ops structures
authorJulia Lawall <Julia.Lawall@lip6.fr>
Wed, 23 Dec 2015 21:59:55 +0000 (22:59 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 1 Jan 2016 23:29:35 +0000 (00:29 +0100)
The powercap_zone_ops and powercap_zone_constraint_ops structures are never
modified, so declare them as const.

Most of the actual changes adjust indentation to accomodate the const
keyword.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/powercap/intel_rapl.c
drivers/powercap/powercap_sys.c
include/linux/powercap.h

index 48747c28a43d4ac2fc1bed10f29cd1224ddd10f0..fa8c8e8eb9f235a1f8d2d1c995c83c926a1ceefd 100644 (file)
@@ -388,7 +388,7 @@ static int get_domain_enable(struct powercap_zone *power_zone, bool *mode)
 }
 
 /* per RAPL domain ops, in the order of rapl_domain_type */
-static struct powercap_zone_ops zone_ops[] = {
+static const struct powercap_zone_ops zone_ops[] = {
        /* RAPL_DOMAIN_PACKAGE */
        {
                .get_energy_uj = get_energy_counter,
@@ -584,7 +584,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id,
        return ret;
 }
 
-static struct powercap_zone_constraint_ops constraint_ops = {
+static const struct powercap_zone_constraint_ops constraint_ops = {
        .set_power_limit_uw = set_power_limit,
        .get_power_limit_uw = get_current_power_limit,
        .set_time_window_us = set_time_window,
index 84419af16f777095687eddb59d74c7ca6762e3bb..14bde0db8c245680fd010bf2f0aa39093af5a4c2 100644 (file)
@@ -293,8 +293,8 @@ err_alloc:
 }
 
 static int create_constraints(struct powercap_zone *power_zone,
-                               int nr_constraints,
-                               struct powercap_zone_constraint_ops *const_ops)
+                       int nr_constraints,
+                       const struct powercap_zone_constraint_ops *const_ops)
 {
        int i;
        int ret = 0;
@@ -492,13 +492,13 @@ static struct class powercap_class = {
 };
 
 struct powercap_zone *powercap_register_zone(
-                               struct powercap_zone *power_zone,
-                               struct powercap_control_type *control_type,
-                               const char *name,
-                               struct powercap_zone *parent,
-                               const struct powercap_zone_ops *ops,
-                               int nr_constraints,
-                               struct powercap_zone_constraint_ops *const_ops)
+                       struct powercap_zone *power_zone,
+                       struct powercap_control_type *control_type,
+                       const char *name,
+                       struct powercap_zone *parent,
+                       const struct powercap_zone_ops *ops,
+                       int nr_constraints,
+                       const struct powercap_zone_constraint_ops *const_ops)
 {
        int result;
        int nr_attrs;
index 4e250417ee30b803838e156c7b74d1da2cb5ef65..f0a4e6257dcc8e8785304cf4a785d91f9d41bedb 100644 (file)
@@ -208,7 +208,7 @@ struct powercap_zone_constraint_ops {
 struct powercap_zone_constraint {
        int id;
        struct powercap_zone *power_zone;
-       struct powercap_zone_constraint_ops *ops;
+       const struct powercap_zone_constraint_ops *ops;
 };
 
 
@@ -309,7 +309,7 @@ struct powercap_zone *powercap_register_zone(
                        struct powercap_zone *parent,
                        const struct powercap_zone_ops *ops,
                        int nr_constraints,
-                       struct powercap_zone_constraint_ops *const_ops);
+                       const struct powercap_zone_constraint_ops *const_ops);
 
 /**
 * powercap_unregister_zone() - Unregister a zone device