Commit b9794a82 authored by Daniel Lezcano's avatar Daniel Lezcano

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: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20220128163537.212248-2-daniel.lezcano@linaro.org
parent 26291c54
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include "dtpm_subsys.h"
#define DTPM_POWER_LIMIT_FLAG 0 #define DTPM_POWER_LIMIT_FLAG 0
static const char *constraint_name[] = { static const char *constraint_name[] = {
......
...@@ -269,4 +269,7 @@ static int __init dtpm_cpu_init(void) ...@@ -269,4 +269,7 @@ static int __init dtpm_cpu_init(void)
return 0; return 0;
} }
DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init); struct dtpm_subsys_ops dtpm_cpu_ops = {
.name = KBUILD_MODNAME,
.init = dtpm_cpu_init,
};
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (C) 2022 Linaro Ltd
*
* Author: Daniel Lezcano <daniel.lezcano@linaro.org>
*/
#ifndef ___DTPM_SUBSYS_H__
#define ___DTPM_SUBSYS_H__
extern struct dtpm_subsys_ops dtpm_cpu_ops;
struct dtpm_subsys_ops *dtpm_subsys[] = {
#ifdef CONFIG_DTPM_CPU
&dtpm_cpu_ops,
#endif
};
#endif
...@@ -321,16 +321,6 @@ ...@@ -321,16 +321,6 @@
#define THERMAL_TABLE(name) #define THERMAL_TABLE(name)
#endif #endif
#ifdef CONFIG_DTPM
#define DTPM_TABLE() \
. = ALIGN(8); \
__dtpm_table = .; \
KEEP(*(__dtpm_table)) \
__dtpm_table_end = .;
#else
#define DTPM_TABLE()
#endif
#define KERNEL_DTB() \ #define KERNEL_DTB() \
STRUCT_ALIGN(); \ STRUCT_ALIGN(); \
__dtb_start = .; \ __dtb_start = .; \
...@@ -723,7 +713,6 @@ ...@@ -723,7 +713,6 @@
ACPI_PROBE_TABLE(irqchip) \ ACPI_PROBE_TABLE(irqchip) \
ACPI_PROBE_TABLE(timer) \ ACPI_PROBE_TABLE(timer) \
THERMAL_TABLE(governor) \ THERMAL_TABLE(governor) \
DTPM_TABLE() \
EARLYCON_TABLE() \ EARLYCON_TABLE() \
LSM_TABLE() \ LSM_TABLE() \
EARLY_LSM_TABLE() \ EARLY_LSM_TABLE() \
......
...@@ -32,29 +32,11 @@ struct dtpm_ops { ...@@ -32,29 +32,11 @@ struct dtpm_ops {
void (*release)(struct dtpm *); void (*release)(struct dtpm *);
}; };
typedef int (*dtpm_init_t)(void); struct dtpm_subsys_ops {
const char *name;
struct dtpm_descr { int (*init)(void);
dtpm_init_t init;
}; };
/* Init section thermal table */
extern struct dtpm_descr __dtpm_table[];
extern struct dtpm_descr __dtpm_table_end[];
#define DTPM_TABLE_ENTRY(name, __init) \
static struct dtpm_descr __dtpm_table_entry_##name \
__used __section("__dtpm_table") = { \
.init = __init, \
}
#define DTPM_DECLARE(name, init) DTPM_TABLE_ENTRY(name, init)
#define for_each_dtpm_table(__dtpm) \
for (__dtpm = __dtpm_table; \
__dtpm < __dtpm_table_end; \
__dtpm++)
static inline struct dtpm *to_dtpm(struct powercap_zone *zone) static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
{ {
return container_of(zone, struct dtpm, zone); return container_of(zone, struct dtpm, zone);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment