Skip to content

Commit b9794a8

Browse files
committed
powercap/drivers/dtpm: Convert the init table section to a simple array
The init table section is freed after the system booted. However the next changes will make per module the DTPM description, so the table won't be accessible when the module is loaded. In order to fix that, we should move the table to the data section where there are very few entries and that makes strange to add it there. The main goal of the table was to keep self-encapsulated code and we can keep it almost as it by using an array instead. Suggested-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20220128163537.212248-2-daniel.lezcano@linaro.org
1 parent 26291c5 commit b9794a8

5 files changed

Lines changed: 27 additions & 33 deletions

File tree

drivers/powercap/dtpm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <linux/slab.h>
2525
#include <linux/mutex.h>
2626

27+
#include "dtpm_subsys.h"
28+
2729
#define DTPM_POWER_LIMIT_FLAG 0
2830

2931
static const char *constraint_name[] = {

drivers/powercap/dtpm_cpu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,7 @@ static int __init dtpm_cpu_init(void)
269269
return 0;
270270
}
271271

272-
DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init);
272+
struct dtpm_subsys_ops dtpm_cpu_ops = {
273+
.name = KBUILD_MODNAME,
274+
.init = dtpm_cpu_init,
275+
};

drivers/powercap/dtpm_subsys.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2022 Linaro Ltd
4+
*
5+
* Author: Daniel Lezcano <daniel.lezcano@linaro.org>
6+
*/
7+
#ifndef ___DTPM_SUBSYS_H__
8+
#define ___DTPM_SUBSYS_H__
9+
10+
extern struct dtpm_subsys_ops dtpm_cpu_ops;
11+
12+
struct dtpm_subsys_ops *dtpm_subsys[] = {
13+
#ifdef CONFIG_DTPM_CPU
14+
&dtpm_cpu_ops,
15+
#endif
16+
};
17+
18+
#endif

include/asm-generic/vmlinux.lds.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,6 @@
321321
#define THERMAL_TABLE(name)
322322
#endif
323323

324-
#ifdef CONFIG_DTPM
325-
#define DTPM_TABLE() \
326-
. = ALIGN(8); \
327-
__dtpm_table = .; \
328-
KEEP(*(__dtpm_table)) \
329-
__dtpm_table_end = .;
330-
#else
331-
#define DTPM_TABLE()
332-
#endif
333-
334324
#define KERNEL_DTB() \
335325
STRUCT_ALIGN(); \
336326
__dtb_start = .; \
@@ -723,7 +713,6 @@
723713
ACPI_PROBE_TABLE(irqchip) \
724714
ACPI_PROBE_TABLE(timer) \
725715
THERMAL_TABLE(governor) \
726-
DTPM_TABLE() \
727716
EARLYCON_TABLE() \
728717
LSM_TABLE() \
729718
EARLY_LSM_TABLE() \

include/linux/dtpm.h

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,11 @@ struct dtpm_ops {
3232
void (*release)(struct dtpm *);
3333
};
3434

35-
typedef int (*dtpm_init_t)(void);
36-
37-
struct dtpm_descr {
38-
dtpm_init_t init;
35+
struct dtpm_subsys_ops {
36+
const char *name;
37+
int (*init)(void);
3938
};
4039

41-
/* Init section thermal table */
42-
extern struct dtpm_descr __dtpm_table[];
43-
extern struct dtpm_descr __dtpm_table_end[];
44-
45-
#define DTPM_TABLE_ENTRY(name, __init) \
46-
static struct dtpm_descr __dtpm_table_entry_##name \
47-
__used __section("__dtpm_table") = { \
48-
.init = __init, \
49-
}
50-
51-
#define DTPM_DECLARE(name, init) DTPM_TABLE_ENTRY(name, init)
52-
53-
#define for_each_dtpm_table(__dtpm) \
54-
for (__dtpm = __dtpm_table; \
55-
__dtpm < __dtpm_table_end; \
56-
__dtpm++)
57-
5840
static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
5941
{
6042
return container_of(zone, struct dtpm, zone);

0 commit comments

Comments
 (0)