Skip to content

Commit 600c395

Browse files
JuliaLawallrafaeljw
authored andcommitted
powercap: constify powercap_zone_ops and powercap_zone_constraint_ops structures
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 74bf8ef commit 600c395

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

drivers/powercap/intel_rapl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static int get_domain_enable(struct powercap_zone *power_zone, bool *mode)
388388
}
389389

390390
/* per RAPL domain ops, in the order of rapl_domain_type */
391-
static struct powercap_zone_ops zone_ops[] = {
391+
static const struct powercap_zone_ops zone_ops[] = {
392392
/* RAPL_DOMAIN_PACKAGE */
393393
{
394394
.get_energy_uj = get_energy_counter,
@@ -584,7 +584,7 @@ static int get_max_power(struct powercap_zone *power_zone, int id,
584584
return ret;
585585
}
586586

587-
static struct powercap_zone_constraint_ops constraint_ops = {
587+
static const struct powercap_zone_constraint_ops constraint_ops = {
588588
.set_power_limit_uw = set_power_limit,
589589
.get_power_limit_uw = get_current_power_limit,
590590
.set_time_window_us = set_time_window,

drivers/powercap/powercap_sys.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ static int seed_constraint_attributes(void)
293293
}
294294

295295
static int create_constraints(struct powercap_zone *power_zone,
296-
int nr_constraints,
297-
struct powercap_zone_constraint_ops *const_ops)
296+
int nr_constraints,
297+
const struct powercap_zone_constraint_ops *const_ops)
298298
{
299299
int i;
300300
int ret = 0;
@@ -492,13 +492,13 @@ static struct class powercap_class = {
492492
};
493493

494494
struct powercap_zone *powercap_register_zone(
495-
struct powercap_zone *power_zone,
496-
struct powercap_control_type *control_type,
497-
const char *name,
498-
struct powercap_zone *parent,
499-
const struct powercap_zone_ops *ops,
500-
int nr_constraints,
501-
struct powercap_zone_constraint_ops *const_ops)
495+
struct powercap_zone *power_zone,
496+
struct powercap_control_type *control_type,
497+
const char *name,
498+
struct powercap_zone *parent,
499+
const struct powercap_zone_ops *ops,
500+
int nr_constraints,
501+
const struct powercap_zone_constraint_ops *const_ops)
502502
{
503503
int result;
504504
int nr_attrs;

include/linux/powercap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct powercap_zone_constraint_ops {
208208
struct powercap_zone_constraint {
209209
int id;
210210
struct powercap_zone *power_zone;
211-
struct powercap_zone_constraint_ops *ops;
211+
const struct powercap_zone_constraint_ops *ops;
212212
};
213213

214214

@@ -309,7 +309,7 @@ struct powercap_zone *powercap_register_zone(
309309
struct powercap_zone *parent,
310310
const struct powercap_zone_ops *ops,
311311
int nr_constraints,
312-
struct powercap_zone_constraint_ops *const_ops);
312+
const struct powercap_zone_constraint_ops *const_ops);
313313

314314
/**
315315
* powercap_unregister_zone() - Unregister a zone device

0 commit comments

Comments
 (0)